Modified: trunk/Source/WebCore/ChangeLog (174650 => 174651)
--- trunk/Source/WebCore/ChangeLog 2014-10-13 17:33:28 UTC (rev 174650)
+++ trunk/Source/WebCore/ChangeLog 2014-10-13 17:44:39 UTC (rev 174651)
@@ -1,3 +1,29 @@
+2014-10-13 Jer Noble <[email protected]>
+
+ [iOS] Stop listening for wireless playback target availability when the default controls are hidden.
+ https://bugs.webkit.org/show_bug.cgi?id=137633
+
+ Reviewed by Dean Jackson.
+
+ In order to minimize the excess bandwidth and power consumption required for actively listening
+ for wireless playback target availablity, unregister for those notifications while the controls
+ are hidden due to playback, or when the element's document is hidden.
+
+ * Modules/mediacontrols/mediaControlsiOS.js:
+ (ControllerIOS.prototype.createBase): Register for document visiblity change notfications.
+ (ControllerIOS.prototype.setControlsType): Call updateShouldListenForPlaybackTargetAvailabilityEvent()
+ instead of setShouldListenForPlaybackTargetAvailabilityEvent()
+ (ControllerIOS.prototype.hideControls): Ditto.
+ (ControllerIOS.prototype.showControls): Ditto.
+ (ControllerIOS.prototype.updateStatusDisplay): Ditto.
+ (ControllerIOS.prototype.handleVisibilityChange): Ditto.
+ (ControllerIOS.prototype.updateShouldListenForPlaybackTargetAvailabilityEvent): Added. Only listen
+ for target availability when the video has no errors, is not in the initial "big play button"
+ controls state, and when the controls are not hidden.
+ * platform/audio/ios/MediaSessionManagerIOS.mm:
+ (-[WebMediaSessionHelper stopMonitoringAirPlayRoutes]): Explicitly set the discoveryMode to "disabled"
+ rather than waiting for the autoreleasepool to destroy our routing controller.
+
2014-10-13 Simon Fraser <[email protected]>
iOS DRT snapshots are limited to the page visible area
Modified: trunk/Source/WebCore/Modules/mediacontrols/mediaControlsiOS.js (174650 => 174651)
--- trunk/Source/WebCore/Modules/mediacontrols/mediaControlsiOS.js 2014-10-13 17:33:28 UTC (rev 174650)
+++ trunk/Source/WebCore/Modules/mediacontrols/mediaControlsiOS.js 2014-10-13 17:44:39 UTC (rev 174651)
@@ -54,6 +54,8 @@
this.listenFor(this.base, 'touchstart', this.handleWrapperTouchStart);
this.stopListeningFor(this.base, 'mousemove', this.handleWrapperMouseMove);
this.stopListeningFor(this.base, 'mouseout', this.handleWrapperMouseOut);
+
+ this.listenFor(document, 'visibilitychange', this.handleVisibilityChange);
},
shouldHaveStartPlaybackButton: function() {
@@ -174,7 +176,7 @@
else
this.removeStartPlaybackControls();
- this.setShouldListenForPlaybackTargetAvailabilityEvent(type !== ControllerIOS.StartPlaybackControls);
+ this.updateShouldListenForPlaybackTargetAvailabilityEvent();
},
addStartPlaybackControls: function() {
@@ -206,6 +208,16 @@
// Do nothing
},
+ hideControls: function() {
+ Controller.prototype.hideControls.call(this);
+ this.updateShouldListenForPlaybackTargetAvailabilityEvent();
+ },
+
+ showControls: function() {
+ Controller.prototype.showControls.call(this);
+ this.updateShouldListenForPlaybackTargetAvailabilityEvent();
+ },
+
updateControls: function() {
if (this.shouldHaveStartPlaybackButton())
this.setControlsType(ControllerIOS.StartPlaybackControls);
@@ -344,6 +356,10 @@
this.video.style.removeProperty('-webkit-user-select');
},
+ handleVisibilityChange: function(event) {
+ this.updateShouldListenForPlaybackTargetAvailabilityEvent();
+ },
+
isFullScreen: function()
{
return this.video.webkitDisplayingFullscreen;
@@ -428,10 +444,23 @@
return true;
},
+ updateShouldListenForPlaybackTargetAvailabilityEvent: function() {
+ var shouldListen = true;
+ if (this.video.error)
+ shouldListen = false;
+ if (this.controlsType === ControllerIOS.StartPlaybackControls)
+ shouldListen = false;
+ if (!this.isAudio() && !this.video.paused && this.controlsAreHidden())
+ shouldListen = false;
+ if (document.hidden)
+ shouldListen = false;
+
+ this.setShouldListenForPlaybackTargetAvailabilityEvent(shouldListen);
+ },
+
updateStatusDisplay: function(event)
{
- if (this.video.error)
- setShouldListenForPlaybackTargetAvailabilityEvent(false);
+ this.updateShouldListenForPlaybackTargetAvailabilityEvent();
this.controls.startPlaybackButton.classList.toggle(this.ClassNames.failed, this.video.error !== null);
Controller.prototype.updateStatusDisplay.call(this, event);
},
Modified: trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm (174650 => 174651)
--- trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm 2014-10-13 17:33:28 UTC (rev 174650)
+++ trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm 2014-10-13 17:44:39 UTC (rev 174651)
@@ -262,6 +262,10 @@
- (void)stopMonitoringAirPlayRoutes
{
+ if (!_airPlayPresenceRoutingController)
+ return;
+
+ [_airPlayPresenceRoutingController setDiscoveryMode:MPRouteDiscoveryModeDisabled];
_airPlayPresenceRoutingController = nil;
}