Diff
Modified: trunk/LayoutTests/ChangeLog (208253 => 208254)
--- trunk/LayoutTests/ChangeLog 2016-11-01 22:31:52 UTC (rev 208253)
+++ trunk/LayoutTests/ChangeLog 2016-11-01 22:55:32 UTC (rev 208254)
@@ -1,3 +1,19 @@
+2016-11-01 Antoine Quint <grao...@apple.com>
+
+ [Modern Media Controls] Media Controller: Airplay support
+ https://bugs.webkit.org/show_bug.cgi?id=163729
+ <rdar://problem/27989484>
+
+ Reviewed by Dean Jackson.
+
+ Adding a new test to check that the AirPlay button in the media controls correctly shows
+ the availability of AirPlay routes and whether the media is playing via AirPlay.
+
+ * media/modern-media-controls/airplay-support/airplay-support-expected.txt: Added.
+ * media/modern-media-controls/airplay-support/airplay-support.html: Added.
+ * platform/ios-simulator/TestExpectations:
+ * platform/mac/TestExpectations:
+
2016-11-01 Dean Jackson <d...@apple.com>
Remove WebKitCSSFilterValue to make Hyatt happy
Added: trunk/LayoutTests/media/modern-media-controls/airplay-support/airplay-support-expected.txt (0 => 208254)
--- trunk/LayoutTests/media/modern-media-controls/airplay-support/airplay-support-expected.txt (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/airplay-support/airplay-support-expected.txt 2016-11-01 22:55:32 UTC (rev 208254)
@@ -0,0 +1,17 @@
+Testing the AirPlaySupport behavior.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Making AirPlay routes available.
+PASS mediaController.controls.airplayButton.enabled is true
+PASS mediaController.controls.airplayButton.on is false
+
+Entering AirPlay playback mode.
+PASS mediaController.controls.airplayButton.enabled is true
+PASS mediaController.controls.airplayButton.on is true
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/media/modern-media-controls/airplay-support/airplay-support.html (0 => 208254)
--- trunk/LayoutTests/media/modern-media-controls/airplay-support/airplay-support.html (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/airplay-support/airplay-support.html 2016-11-01 22:55:32 UTC (rev 208254)
@@ -0,0 +1,61 @@
+<script src=""
+<script src="" type="text/_javascript_"></script>
+<body>
+<video src="" style="width: 320px; height: 240px;" autoplay></video>
+<div id="host"></div>
+<script type="text/_javascript_">
+
+window.jsTestIsAsync = true;
+
+description("Testing the <code>AirPlaySupport</code> behavior.");
+
+iconService.directoryPath = "../../../../Source/WebCore/Modules/modern-media-controls/images";
+
+const container = document.querySelector("div#host");
+const media = document.querySelector("video");
+const mediaController = createControls(container, media, null);
+
+window.internals.setMockMediaPlaybackTargetPickerEnabled(false);
+
+media.addEventListener("play", () => {
+ media.addEventListener("webkitplaybacktargetavailabilitychanged", playbackTargetAvailabilityChanged);
+ media.addEventListener("webkitcurrentplaybacktargetiswirelesschanged", currentPlaybackTargetIsWirelessChanged);
+
+ debug("Making AirPlay routes available.");
+ window.internals.setMockMediaPlaybackTargetPickerEnabled(true);
+});
+
+let playbackTargetBecameAvailable = false;
+function playbackTargetAvailabilityChanged(event)
+{
+ if (event.availability == "available" && !playbackTargetBecameAvailable) {
+ playbackTargetBecameAvailable = true;
+ shouldBeTrue("mediaController.controls.airplayButton.enabled");
+ shouldBeFalse("mediaController.controls.airplayButton.on");
+
+ debug("");
+ debug("Entering AirPlay playback mode.");
+ window.internals.setMockMediaPlaybackTargetPickerState("Sleepy TV", "DeviceAvailable");
+ media.webkitShowPlaybackTargetPicker();
+ }
+}
+
+function currentPlaybackTargetIsWirelessChanged(event)
+{
+ if (!media.webkitCurrentPlaybackTargetIsWireless)
+ return;
+
+ shouldBeTrue("mediaController.controls.airplayButton.enabled");
+ shouldBeTrue("mediaController.controls.airplayButton.on");
+
+ debug("");
+ container.remove();
+ media.remove();
+ finishJSTest();
+}
+
+setTimeout(finishJSTest, 3000);
+
+</script>
+<script src=""
+</body>
Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (208253 => 208254)
--- trunk/LayoutTests/platform/ios-simulator/TestExpectations 2016-11-01 22:31:52 UTC (rev 208253)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations 2016-11-01 22:55:32 UTC (rev 208254)
@@ -2744,3 +2744,4 @@
# Internal APIs to test PiP and AirPlay are not available on iOS.
media/modern-media-controls/placard-support [ Skip ]
+media/modern-media-controls/airplay-support/airplay-support.html [ Skip ]
Modified: trunk/LayoutTests/platform/mac/TestExpectations (208253 => 208254)
--- trunk/LayoutTests/platform/mac/TestExpectations 2016-11-01 22:31:52 UTC (rev 208253)
+++ trunk/LayoutTests/platform/mac/TestExpectations 2016-11-01 22:55:32 UTC (rev 208254)
@@ -1453,5 +1453,6 @@
# Internal APIs to test PiP and AirPlay are not available on Yosemite.
[ Yosemite ] media/modern-media-controls/placard-support [ Skip ]
+[ Yosemite ] media/modern-media-controls/airplay-support/airplay-support.html [ Skip ]
webkit.org/b/164277 fast/preloader/image-srcset.html [ Pass Failure ]
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (208253 => 208254)
--- trunk/Source/WebCore/ChangeLog 2016-11-01 22:31:52 UTC (rev 208253)
+++ trunk/Source/WebCore/ChangeLog 2016-11-01 22:55:32 UTC (rev 208254)
@@ -1,3 +1,32 @@
+2016-11-01 Antoine Quint <grao...@apple.com>
+
+ [Modern Media Controls] Media Controller: Airplay support
+ https://bugs.webkit.org/show_bug.cgi?id=163729
+ <rdar://problem/27989484>
+
+ Reviewed by Dean Jackson.
+
+ We introduce the AirplaySupport class which brings support for playing the media
+ via Airplay by clicking on the Airplay button in the media controls and correctly
+ reflecting when the media is played through Airplay via the media API. The enabled
+ state of the Airplay button is also tied to Airplay sources being available.
+
+ Test: media/modern-media-controls/airplay-support/airplay-support.html
+
+ * Modules/modern-media-controls/controls/airplay-button.js:
+ (AirplayButton.prototype.get on):
+ * Modules/modern-media-controls/js-files:
+ * Modules/modern-media-controls/media/airplay-support.js: Added.
+ (AirplaySupport.prototype.get control):
+ (AirplaySupport.prototype.get mediaEvents):
+ (AirplaySupport.prototype.buttonWasClicked):
+ (AirplaySupport.prototype.handleEvent):
+ (AirplaySupport.prototype.syncControl):
+ (AirplaySupport):
+ * Modules/modern-media-controls/media/media-controller.js:
+ (MediaController):
+ * WebCore.xcodeproj/project.pbxproj:
+
2016-11-01 Dean Jackson <d...@apple.com>
Remove WebKitCSSFilterValue to make Hyatt happy
Modified: trunk/Source/WebCore/Modules/modern-media-controls/controls/airplay-button.js (208253 => 208254)
--- trunk/Source/WebCore/Modules/modern-media-controls/controls/airplay-button.js 2016-11-01 22:31:52 UTC (rev 208253)
+++ trunk/Source/WebCore/Modules/modern-media-controls/controls/airplay-button.js 2016-11-01 22:55:32 UTC (rev 208254)
@@ -37,6 +37,11 @@
// Public
+ get on()
+ {
+ return this.element.classList.contains("on");
+ }
+
set on(flag) {
this.element.classList.toggle("on", flag);
}
Modified: trunk/Source/WebCore/Modules/modern-media-controls/js-files (208253 => 208254)
--- trunk/Source/WebCore/Modules/modern-media-controls/js-files 2016-11-01 22:31:52 UTC (rev 208253)
+++ trunk/Source/WebCore/Modules/modern-media-controls/js-files 2016-11-01 22:55:32 UTC (rev 208254)
@@ -28,6 +28,7 @@
controls/airplay-placard.js
controls/pip-placard.js
media/media-controller-support.js
+media/airplay-support.js
media/elapsed-time-support.js
media/mute-support.js
media/placard-support.js
Copied: trunk/Source/WebCore/Modules/modern-media-controls/media/airplay-support.js (from rev 208253, trunk/Source/WebCore/Modules/modern-media-controls/controls/airplay-button.js) (0 => 208254)
--- trunk/Source/WebCore/Modules/modern-media-controls/media/airplay-support.js (rev 0)
+++ trunk/Source/WebCore/Modules/modern-media-controls/media/airplay-support.js 2016-11-01 22:55:32 UTC (rev 208254)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+class AirplaySupport extends MediaControllerSupport
+{
+
+ // Protected
+
+ get control()
+ {
+ return this.mediaController.controls.airplayButton;
+ }
+
+ get mediaEvents()
+ {
+ return ["webkitplaybacktargetavailabilitychanged", "webkitcurrentplaybacktargetiswirelesschanged"];
+ }
+
+ buttonWasClicked(control)
+ {
+ this.mediaController.media.webkitShowPlaybackTargetPicker();
+ }
+
+ handleEvent(event)
+ {
+ if (event.type === "webkitplaybacktargetavailabilitychanged")
+ this._routesAvailable = event.availability === "available";
+
+ super.handleEvent(event);
+ }
+
+ syncControl()
+ {
+ this.control.enabled = !!this._routesAvailable;
+ this.control.on = this.mediaController.media.webkitCurrentPlaybackTargetIsWireless;
+ }
+
+}
Modified: trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js (208253 => 208254)
--- trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js 2016-11-01 22:31:52 UTC (rev 208253)
+++ trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js 2016-11-01 22:55:32 UTC (rev 208254)
@@ -38,6 +38,7 @@
this.controls = new MacOSInlineMediaControls
shadowRoot.appendChild(this.controls.element);
+ new AirplaySupport(this);
new ElapsedTimeSupport(this);
new MuteSupport(this);
new PlacardSupport(this);
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (208253 => 208254)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-11-01 22:31:52 UTC (rev 208253)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-11-01 22:55:32 UTC (rev 208254)
@@ -9915,6 +9915,7 @@
7177E2471DB80D2F00919A0B /* mute-support.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; path = "mute-support.js"; sourceTree = "<group>"; };
7177E2481DB80D2F00919A0B /* start-support.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; path = "start-support.js"; sourceTree = "<group>"; };
717F90571DC40ED60006F520 /* volume-support.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; path = "volume-support.js"; sourceTree = "<group>"; };
+ 717F90581DC4BB600006F520 /* airplay-support.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; path = "airplay-support.js"; sourceTree = "<group>"; };
71A57DEF154BE25C0009D120 /* SVGPathUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGPathUtilities.cpp; sourceTree = "<group>"; };
71A57DF0154BE25C0009D120 /* SVGPathUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPathUtilities.h; sourceTree = "<group>"; };
71B1E123164048CC00B1880A /* InspectorLayerTreeAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorLayerTreeAgent.cpp; sourceTree = "<group>"; };
@@ -17869,6 +17870,7 @@
71D02D911DB55C4E00DD5CF5 /* media */ = {
isa = PBXGroup;
children = (
+ 717F90581DC4BB600006F520 /* airplay-support.js */,
71004B9A1DC1109300A52A38 /* elapsed-time-support.js */,
7177E2461DB80D2F00919A0B /* media-controller-support.js */,
71D02D921DB55C4E00DD5CF5 /* media-controller.js */,