Title: [200466] trunk/Source/WebCore
Revision
200466
Author
[email protected]
Date
2016-05-05 11:51:50 -0700 (Thu, 05 May 2016)

Log Message

[iOS] Media information is sometimes not shown in Control Center
https://bugs.webkit.org/show_bug.cgi?id=157377

Reviewed by Jer Noble.

* platform/audio/ios/MediaSessionManagerIOS.h:
* platform/audio/ios/MediaSessionManagerIOS.mm:
(WebCore::MediaSessionManageriOS::updateNowPlayingInfo): Store values passed to MPNowPlayingInfoCenter
  individually instead of in a dictionary.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (200465 => 200466)


--- trunk/Source/WebCore/ChangeLog	2016-05-05 18:36:22 UTC (rev 200465)
+++ trunk/Source/WebCore/ChangeLog	2016-05-05 18:51:50 UTC (rev 200466)
@@ -1,3 +1,15 @@
+2016-05-05  Eric Carlson  <[email protected]>
+
+        [iOS] Media information is sometimes not shown in Control Center
+        https://bugs.webkit.org/show_bug.cgi?id=157377
+
+        Reviewed by Jer Noble.
+
+        * platform/audio/ios/MediaSessionManagerIOS.h:
+        * platform/audio/ios/MediaSessionManagerIOS.mm:
+        (WebCore::MediaSessionManageriOS::updateNowPlayingInfo): Store values passed to MPNowPlayingInfoCenter
+          individually instead of in a dictionary.
+
 2016-05-04  Simon Fraser  <[email protected]>
 
         Comments on wired.com are blurry

Modified: trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h (200465 => 200466)


--- trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h	2016-05-05 18:36:22 UTC (rev 200465)
+++ trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h	2016-05-05 18:51:50 UTC (rev 200466)
@@ -73,7 +73,10 @@
     PlatformMediaSession* nowPlayingEligibleSession();
     
     RetainPtr<WebMediaSessionHelper> m_objcObserver;
-    RetainPtr<NSMutableDictionary> m_nowPlayingInfo;
+    double m_reportedRate { 0 };
+    double m_reportedDuration { 0 };
+    String m_reportedTitle;
+    bool m_nowPlayingActive { false };
     bool m_isInBackground { false };
 };
 

Modified: trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm (200465 => 200466)


--- trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm	2016-05-05 18:36:22 UTC (rev 200465)
+++ trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm	2016-05-05 18:51:50 UTC (rev 200466)
@@ -240,40 +240,42 @@
     LOG(Media, "MediaSessionManageriOS::updateNowPlayingInfo - currentSession = %p", currentSession);
 
     if (!currentSession) {
-        if (m_nowPlayingInfo) {
+        if (m_nowPlayingActive) {
             LOG(Media, "MediaSessionManageriOS::updateNowPlayingInfo - clearing now playing info");
             [nowPlaying setNowPlayingInfo:nil];
-            m_nowPlayingInfo = nil;
+            m_nowPlayingActive = false;
         }
 
         return;
     }
 
-    RetainPtr<NSMutableDictionary> info = adoptNS([[NSMutableDictionary alloc] init]);
-
     String title = currentSession->title();
-    if (!title.isEmpty())
-        [info setValue:static_cast<NSString *>(title) forKey:MPMediaItemPropertyTitle];
-
     double duration = currentSession->duration();
-    if (std::isfinite(duration) && duration != MediaPlayer::invalidTime())
-        [info setValue:@(duration) forKey:MPMediaItemPropertyPlaybackDuration];
-
-    [info setValue:(currentSession->state() == PlatformMediaSession::Playing ? @YES : @NO) forKey:MPNowPlayingInfoPropertyPlaybackRate];
-
-    if ([m_nowPlayingInfo.get() isEqualToDictionary:info.get()]) {
+    double rate = currentSession->state() == PlatformMediaSession::Playing ? 1 : 0;
+    if (m_reportedTitle == title && m_reportedRate == rate && m_reportedDuration == duration) {
         LOG(Media, "MediaSessionManageriOS::updateNowPlayingInfo - nothing new to show");
         return;
     }
 
-    m_nowPlayingInfo = info;
+    m_reportedRate = rate;
+    m_reportedDuration = duration;
+    m_reportedTitle = title;
 
+    auto info = adoptNS([[NSMutableDictionary alloc] init]);
+    if (!title.isEmpty())
+        info.get()[MPMediaItemPropertyTitle] = static_cast<NSString *>(title);
+    if (std::isfinite(duration) && duration != MediaPlayer::invalidTime())
+        info.get()[MPMediaItemPropertyPlaybackDuration] = @(duration);
+    info.get()[MPNowPlayingInfoPropertyPlaybackRate] = @(rate);
+
     double currentTime = currentSession->currentTime();
     if (std::isfinite(currentTime) && currentTime != MediaPlayer::invalidTime())
-        [info setValue:@(currentTime) forKey:MPNowPlayingInfoPropertyElapsedPlaybackTime];
+        info.get()[MPNowPlayingInfoPropertyElapsedPlaybackTime] = @(currentTime);
 
-    LOG(Media, "MediaSessionManageriOS::updateNowPlayingInfo - title = \"%s\"", [[info.get() valueForKey:MPMediaItemPropertyTitle] UTF8String]);
+    LOG(Media, "MediaSessionManageriOS::updateNowPlayingInfo - title = \"%s\", rate = %f, duration = %f, now = %f",
+        title.utf8().data(), rate, duration, currentTime);
 
+    m_nowPlayingActive = true;
     [nowPlaying setNowPlayingInfo:info.get()];
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to