Changeset 185914 in webkit
- Timestamp:
- Jun 24, 2015 9:38:55 AM (9 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r185912 r185914 1 2015-06-23 Matt Rajca <mrajca@apple.com> 2 3 MediaSession: Support setting of metadata 4 https://bugs.webkit.org/show_bug.cgi?id=146253 5 6 Reviewed by Eric Carlson. 7 8 * Modules/mediasession/MediaSession.cpp: 9 (WebCore::MediaSession::MediaSession): Store a reference to the document so we can use it in setMetadata. 10 (WebCore::MediaSession::setMetadata): Implemented as described in the Media Session spec. 11 * Modules/mediasession/MediaSession.h: 12 * Modules/mediasession/MediaSession.idl: Added the setMetadata method. 13 * Modules/mediasession/MediaSessionMetadata.h: 14 (WebCore::MediaSessionMetadata::MediaSessionMetadata): Added to keep track of media session metadata. 15 (WebCore::MediaSessionMetadata::title): 16 (WebCore::MediaSessionMetadata::artist): 17 (WebCore::MediaSessionMetadata::album): 18 (WebCore::MediaSessionMetadata::artworkURL): 19 * WebCore.xcodeproj/project.pbxproj: Added MediaSessionMetadata.h. 20 1 21 2015-06-24 Daniel Bates <dabates@apple.com> 2 22 -
trunk/Source/WebCore/Modules/mediasession/MediaSession.cpp
r185885 r185914 29 29 #if ENABLE(MEDIA_SESSION) 30 30 31 #include "Dictionary.h" 31 32 #include "Event.h" 32 33 #include "HTMLMediaElement.h" … … 36 37 37 38 MediaSession::MediaSession(ScriptExecutionContext& context, const String& kind) 38 : m_kind(kind) 39 : m_document(downcast<Document>(context)) 40 , m_kind(kind) 39 41 { 40 42 if (m_kind == "content") … … 71 73 { 72 74 m_activeParticipatingElements.add(&element); 75 } 76 77 void MediaSession::setMetadata(const Dictionary& metadata) 78 { 79 // 5.1.3 80 // 1. Let media session be the current media session. 81 // 2. Let baseURL be the API base URL specified by the entry settings object. 82 // 3. Set media session's title to metadata's title. 83 String title; 84 metadata.get("title", title); 85 86 // 4. Set media session's artist name to metadata's artist. 87 String artist; 88 metadata.get("artist", artist); 89 90 // 5. Set media session's album name to metadata's album. 91 String album; 92 metadata.get("album", album); 93 94 // 6. If metadata's artwork is present, parse it using baseURL, and if that does not return failure, set media 95 // session's artwork URL to the return value. 96 URL artworkURL; 97 String artworkPath; 98 if (metadata.get("artwork", artworkPath)) 99 artworkURL = m_document.completeURL(artworkPath); 100 101 m_metadata = MediaSessionMetadata(title, artist, album, artworkURL); 73 102 } 74 103 -
trunk/Source/WebCore/Modules/mediasession/MediaSession.h
r185885 r185914 30 30 31 31 #include "MediaRemoteControls.h" 32 #include "MediaSessionMetadata.h" 32 33 33 34 namespace WebCore { 34 35 36 class Dictionary; 37 class Document; 35 38 class HTMLMediaElement; 36 39 … … 42 45 Interrupted 43 46 }; 44 47 45 48 static Ref<MediaSession> create(ScriptExecutionContext& context, const String& kind) 46 49 { … … 55 58 56 59 State currentState() const { return m_currentState; } 60 61 void setMetadata(const Dictionary&); 57 62 58 63 void releaseSession(); … … 80 85 HashSet<HTMLMediaElement*>* m_iteratedActiveParticipatingElements { nullptr }; 81 86 87 Document& m_document; 82 88 const String m_kind; 83 89 RefPtr<MediaRemoteControls> m_controls; 90 MediaSessionMetadata m_metadata; 84 91 }; 85 92 -
trunk/Source/WebCore/Modules/mediasession/MediaSession.idl
r185126 r185914 33 33 readonly attribute MediaRemoteControls? controls; 34 34 35 void setMetadata(Dictionary metadata); 36 35 37 void releaseSession(); 36 38 }; -
trunk/Source/WebCore/Modules/mediasession/MediaSessionMetadata.h
r185912 r185914 1 1 /* 2 * Copyright (C) 2015 Apple Inc. All rights reserved.2 * Copyright (C) 2015 Apple Inc. All Rights Reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 [ 27 Conditional=MEDIA_SESSION, 28 Constructor(MediaSessionKind kind), 29 ConstructorCallWith=ScriptExecutionContext, 30 ImplementationLacksVTable, 31 ] interface MediaSession { 32 readonly attribute MediaSessionKind kind; 33 readonly attribute MediaRemoteControls? controls; 26 #ifndef MediaSessionMetadata_h 27 #define MediaSessionMetadata_h 34 28 35 void releaseSession(); 29 #if ENABLE(MEDIA_SESSION) 30 31 #include "URL.h" 32 33 namespace WebCore { 34 35 struct MediaSessionMetadata { 36 MediaSessionMetadata() = default; 37 38 MediaSessionMetadata(const String& title, const String& artist, const String& album, const URL& artworkURL) 39 : m_title(title) 40 , m_artist(artist) 41 , m_album(album) 42 , m_artworkURL(artworkURL) { } 43 44 String title() const { return m_title; } 45 String artist() const { return m_artist; } 46 String album() const { return m_album; } 47 URL artworkURL() const { return m_artworkURL; } 48 49 private: 50 String m_title; 51 String m_artist; 52 String m_album; 53 URL m_artworkURL; 36 54 }; 37 55 38 enum MediaSessionKind { 39 "content", 40 "transient", 41 "transient-solo", 42 "ambient" 43 }; 56 } // namespace WebCore 57 58 #endif /* ENABLE(MEDIA_SESSION) */ 59 60 #endif /* MediaSessionMetadata_h */ -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r185888 r185914 5710 5710 C937FE8D1B1F6821008ECC5D /* HTMLMediaElementMediaSession.h in Headers */ = {isa = PBXBuildFile; fileRef = C968B2E61B1E72F700EF1F81 /* HTMLMediaElementMediaSession.h */; }; 5711 5711 C968B2E81B1E778100EF1F81 /* HTMLMediaElementMediaSession.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C968B2E71B1E778100EF1F81 /* HTMLMediaElementMediaSession.cpp */; }; 5712 C9D851F01B39DC780085062E /* MediaSessionMetadata.h in Headers */ = {isa = PBXBuildFile; fileRef = C9D851EE1B39DC780085062E /* MediaSessionMetadata.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5712 5713 C9DADBCB1B1D3B97001F17D8 /* JSMediaSession.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C9DADBC91B1D3B25001F17D8 /* JSMediaSession.cpp */; }; 5713 5714 C9F87CFE1B28F40E00979B83 /* MediaEventTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = C9F87CFD1B28E5F600979B83 /* MediaEventTypes.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 13292 13293 C968B2E61B1E72F700EF1F81 /* HTMLMediaElementMediaSession.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HTMLMediaElementMediaSession.h; sourceTree = "<group>"; }; 13293 13294 C968B2E71B1E778100EF1F81 /* HTMLMediaElementMediaSession.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLMediaElementMediaSession.cpp; sourceTree = "<group>"; }; 13295 C9D851EE1B39DC780085062E /* MediaSessionMetadata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSessionMetadata.h; sourceTree = "<group>"; }; 13294 13296 C9DADBC91B1D3B25001F17D8 /* JSMediaSession.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaSession.cpp; sourceTree = "<group>"; }; 13295 13297 C9DADBCA1B1D3B25001F17D8 /* JSMediaSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMediaSession.h; sourceTree = "<group>"; }; … … 14650 14652 C90F65531B225396002163A1 /* MediaSessionManager.cpp */, 14651 14653 C90F65541B225396002163A1 /* MediaSessionManager.h */, 14654 C9D851EE1B39DC780085062E /* MediaSessionMetadata.h */, 14652 14655 0709D78C1AE55554004E42F8 /* WebMediaSessionManager.cpp */, 14653 14656 0709D78D1AE55554004E42F8 /* WebMediaSessionManager.h */, … … 25901 25904 C90F65561B2253BE002163A1 /* MediaSessionManager.h in Headers */, 25902 25905 07638A991884487200E15A1B /* MediaSessionManagerIOS.h in Headers */, 25906 C9D851F01B39DC780085062E /* MediaSessionMetadata.h in Headers */, 25903 25907 CD3A495F17A9D01B00274E42 /* MediaSource.h in Headers */, 25904 25908 CD641EB31818F5ED00EE4C41 /* MediaSourcePrivate.h in Headers */,
Note: See TracChangeset
for help on using the changeset viewer.