Diff
Modified: trunk/Source/WebCore/ChangeLog (227278 => 227279)
--- trunk/Source/WebCore/ChangeLog 2018-01-22 02:38:51 UTC (rev 227278)
+++ trunk/Source/WebCore/ChangeLog 2018-01-22 03:30:35 UTC (rev 227279)
@@ -1,3 +1,34 @@
+2018-01-21 Eric Carlson <[email protected]>
+
+ Resign NowPlaying status when no media element is eligible
+ https://bugs.webkit.org/show_bug.cgi?id=181914
+ <rdar://problem/35294116>
+
+ Reviewed by Jer Noble.
+
+ Updated API test.
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::removedFromAncestor): Call mediaSession->clientCharacteristicsChanged
+ so NowPlaying status will be updated.
+
+ * html/MediaElementSession.cpp:
+ (WebCore::MediaElementSession::canShowControlsManager const): Return false when being queried
+ for NowPlaying status in an inactive document.
+
+ * platform/audio/PlatformMediaSessionManager.cpp:
+ (WebCore::PlatformMediaSessionManager::updateNowPlayingInfoIfNecessary): Implement in for all
+ ports.
+ * platform/audio/PlatformMediaSessionManager.h:
+ (WebCore::PlatformMediaSessionManager::registeredAsNowPlayingApplication const):
+ * platform/audio/ios/MediaSessionManagerIOS.h:
+ * platform/audio/mac/MediaSessionManagerMac.h:
+ * platform/audio/mac/MediaSessionManagerMac.mm:
+ (WebCore::MediaSessionManagerMac::updateNowPlayingInfo): Call MRMediaRemoteSetCanBeNowPlayingApplication
+ whenever status changes.
+ (WebCore::PlatformMediaSessionManager::updateNowPlayingInfoIfNecessary): Deleted, implemented
+ in the base class.
+
2018-01-21 Jer Noble <[email protected]>
REGRESSION (macOS 10.13.2): imported/w3c/web-platform-tests/media-source/mediasource-* LayoutTests failing
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (227278 => 227279)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2018-01-22 02:38:51 UTC (rev 227278)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2018-01-22 03:30:35 UTC (rev 227279)
@@ -971,6 +971,9 @@
m_pauseAfterDetachedTaskQueue.enqueueTask(std::bind(&HTMLMediaElement::pauseAfterDetachedTask, this));
}
+ if (m_mediaSession)
+ m_mediaSession->clientCharacteristicsChanged();
+
HTMLElement::removedFromAncestor(removalType, oldParentOfRemovedTree);
}
Modified: trunk/Source/WebCore/html/MediaElementSession.cpp (227278 => 227279)
--- trunk/Source/WebCore/html/MediaElementSession.cpp 2018-01-22 02:38:51 UTC (rev 227278)
+++ trunk/Source/WebCore/html/MediaElementSession.cpp 2018-01-22 03:30:35 UTC (rev 227279)
@@ -379,6 +379,11 @@
}
if (purpose == PlaybackControlsPurpose::NowPlaying) {
+ if (!m_element.inActiveDocument()) {
+ LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: Not in active document");
+ return false;
+ }
+
LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: Potentially plays audio");
return true;
}
Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp (227278 => 227279)
--- trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp 2018-01-22 02:38:51 UTC (rev 227278)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp 2018-01-22 03:30:35 UTC (rev 227279)
@@ -33,12 +33,6 @@
namespace WebCore {
-#if !PLATFORM(MAC)
-void PlatformMediaSessionManager::updateNowPlayingInfoIfNecessary()
-{
-}
-#endif
-
#if ENABLE(VIDEO) || ENABLE(WEB_AUDIO)
#if !PLATFORM(COCOA)
@@ -57,6 +51,12 @@
}
#endif // !PLATFORM(COCOA)
+void PlatformMediaSessionManager::updateNowPlayingInfoIfNecessary()
+{
+ if (auto existingManager = PlatformMediaSessionManager::sharedManagerIfExists())
+ existingManager->scheduleUpdateNowPlayingInfo();
+}
+
PlatformMediaSessionManager::PlatformMediaSessionManager()
: m_systemSleepListener(PAL::SystemSleepListener::create(*this))
{
Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h (227278 => 227279)
--- trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h 2018-01-22 02:38:51 UTC (rev 227278)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h 2018-01-22 03:30:35 UTC (rev 227279)
@@ -61,6 +61,7 @@
WEBCORE_EXPORT virtual double lastUpdatedNowPlayingDuration() const { return NAN; }
WEBCORE_EXPORT virtual double lastUpdatedNowPlayingElapsedTime() const { return NAN; }
WEBCORE_EXPORT virtual uint64_t lastUpdatedNowPlayingInfoUniqueIdentifier() const { return 0; }
+ WEBCORE_EXPORT virtual bool registeredAsNowPlayingApplication() const { return false; }
bool willIgnoreSystemInterruptions() const { return m_willIgnoreSystemInterruptions; }
void setWillIgnoreSystemInterruptions(bool ignore) { m_willIgnoreSystemInterruptions = ignore; }
Modified: trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h (227278 => 227279)
--- trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h 2018-01-22 02:38:51 UTC (rev 227278)
+++ trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h 2018-01-22 03:30:35 UTC (rev 227279)
@@ -73,6 +73,7 @@
double lastUpdatedNowPlayingDuration() const final { return m_reportedDuration; }
double lastUpdatedNowPlayingElapsedTime() const final { return m_reportedCurrentTime; }
uint64_t lastUpdatedNowPlayingInfoUniqueIdentifier() const final { return m_lastUpdatedNowPlayingInfoUniqueIdentifier; }
+ bool registeredAsNowPlayingApplication() const final { return m_nowPlayingActive; }
PlatformMediaSession* nowPlayingEligibleSession();
Modified: trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.h (227278 => 227279)
--- trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.h 2018-01-22 02:38:51 UTC (rev 227278)
+++ trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.h 2018-01-22 03:30:35 UTC (rev 227279)
@@ -41,6 +41,7 @@
double lastUpdatedNowPlayingDuration() const final { return m_lastUpdatedNowPlayingDuration; }
double lastUpdatedNowPlayingElapsedTime() const final { return m_lastUpdatedNowPlayingElapsedTime; }
uint64_t lastUpdatedNowPlayingInfoUniqueIdentifier() const final { return m_lastUpdatedNowPlayingInfoUniqueIdentifier; }
+ bool registeredAsNowPlayingApplication() const final { return m_registeredAsNowPlayingApplication; }
private:
friend class PlatformMediaSessionManager;
@@ -61,6 +62,7 @@
bool m_nowPlayingActive { false };
bool m_isInBackground { false };
+ bool m_registeredAsNowPlayingApplication { false };
// For testing purposes only.
String m_lastUpdatedNowPlayingTitle;
Modified: trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm (227278 => 227279)
--- trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm 2018-01-22 02:38:51 UTC (rev 227278)
+++ trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm 2018-01-22 03:30:35 UTC (rev 227279)
@@ -54,12 +54,6 @@
return platformMediaSessionManager;
}
-void PlatformMediaSessionManager::updateNowPlayingInfoIfNecessary()
-{
- if (auto existingManager = (MediaSessionManagerMac *)PlatformMediaSessionManager::sharedManagerIfExists())
- existingManager->scheduleUpdateNowPlayingInfo();
-}
-
MediaSessionManagerMac::MediaSessionManagerMac()
: PlatformMediaSessionManager()
{
@@ -136,6 +130,10 @@
MRMediaRemoteSetNowPlayingVisibility(MRMediaRemoteGetLocalOrigin(), MRNowPlayingClientVisibilityNeverVisible);
LOG(Media, "MediaSessionManagerMac::updateNowPlayingInfo - clearing now playing info");
+
+ MRMediaRemoteSetCanBeNowPlayingApplication(false);
+ m_registeredAsNowPlayingApplication = false;
+
MRMediaRemoteSetNowPlayingInfo(nullptr);
m_nowPlayingActive = false;
m_lastUpdatedNowPlayingTitle = emptyString();
@@ -154,10 +152,10 @@
return;
}
- static dispatch_once_t enableNowPlayingToken;
- dispatch_once(&enableNowPlayingToken, ^() {
+ if (!m_registeredAsNowPlayingApplication) {
+ m_registeredAsNowPlayingApplication = true;
MRMediaRemoteSetCanBeNowPlayingApplication(true);
- });
+ }
String title = currentSession->title();
double duration = currentSession->supportsSeeking() ? currentSession->duration() : MediaPlayer::invalidTime();
Modified: trunk/Source/WebKit/ChangeLog (227278 => 227279)
--- trunk/Source/WebKit/ChangeLog 2018-01-22 02:38:51 UTC (rev 227278)
+++ trunk/Source/WebKit/ChangeLog 2018-01-22 03:30:35 UTC (rev 227279)
@@ -1,3 +1,23 @@
+2018-01-21 Eric Carlson <[email protected]>
+
+ Resign NowPlaying status when no media element is eligible
+ https://bugs.webkit.org/show_bug.cgi?id=181914
+ <rdar://problem/35294116>
+
+ Reviewed by Jer Noble.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _requestActiveNowPlayingSessionInfo:]): Return registeredAsNowPlayingApplication
+ status.
+ * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::nowPlayingInfoCallback): Ditto.
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPageProxy.messages.in:
+ * WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
+ (WebKit::WebPage::requestActiveNowPlayingSessionInfo): Ditto.
+
2018-01-20 Andy Estes <[email protected]>
[Apple Pay] Stop eagerly loading PassKit.framework
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (227278 => 227279)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2018-01-22 02:38:51 UTC (rev 227278)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2018-01-22 03:30:35 UTC (rev 227279)
@@ -6074,16 +6074,16 @@
#endif // PLATFORM(MAC)
-- (void)_requestActiveNowPlayingSessionInfo:(void(^)(BOOL, NSString*, double, double, NSInteger))callback
+- (void)_requestActiveNowPlayingSessionInfo:(void(^)(BOOL, BOOL, NSString*, double, double, NSInteger))callback
{
if (!_page) {
- callback(NO, @"", std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(), 0);
+ callback(NO, NO, @"", std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(), 0);
return;
}
auto handler = makeBlockPtr(callback);
- auto localCallback = WebKit::NowPlayingInfoCallback::create([handler](bool active, String title, double duration, double elapsedTime, uint64_t uniqueIdentifier, WebKit::CallbackBase::Error) {
- handler(active, title, duration, elapsedTime, uniqueIdentifier);
+ auto localCallback = WebKit::NowPlayingInfoCallback::create([handler](bool active, bool registeredAsNowPlayingApplication, String title, double duration, double elapsedTime, uint64_t uniqueIdentifier, WebKit::CallbackBase::Error) {
+ handler(active, registeredAsNowPlayingApplication, title, duration, elapsedTime, uniqueIdentifier);
});
_page->requestActiveNowPlayingSessionInfo(WTFMove(localCallback));
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h (227278 => 227279)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h 2018-01-22 02:38:51 UTC (rev 227278)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h 2018-01-22 03:30:35 UTC (rev 227279)
@@ -442,7 +442,7 @@
- (void)_setFooterBannerHeight:(int)height WK_API_AVAILABLE(macosx(10.12.3));
#endif
-- (void)_requestActiveNowPlayingSessionInfo:(void(^)(BOOL, NSString*, double, double, NSInteger))callback WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (void)_requestActiveNowPlayingSessionInfo:(void(^)(BOOL, BOOL, NSString*, double, double, NSInteger))callback WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
- (void)_setPageScale:(CGFloat)scale withOrigin:(CGPoint)origin WK_API_AVAILABLE(ios(10.3));
- (CGFloat)_pageScale WK_API_AVAILABLE(ios(10.3));
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (227278 => 227279)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2018-01-22 02:38:51 UTC (rev 227278)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2018-01-22 03:30:35 UTC (rev 227279)
@@ -6807,7 +6807,7 @@
m_process->send(Messages::WebPage::RequestActiveNowPlayingSessionInfo(callbackID), m_pageID);
}
-void WebPageProxy::nowPlayingInfoCallback(bool hasActiveSession, const String& title, double duration, double elapsedTime, uint64_t uniqueIdentifier, CallbackID callbackID)
+void WebPageProxy::nowPlayingInfoCallback(bool hasActiveSession, bool registeredAsNowPlayingApplication, const String& title, double duration, double elapsedTime, uint64_t uniqueIdentifier, CallbackID callbackID)
{
auto callback = m_callbacks.take<NowPlayingInfoCallback>(callbackID);
if (!callback) {
@@ -6815,7 +6815,7 @@
return;
}
- callback->performCallbackWithReturnValue(hasActiveSession, title, duration, elapsedTime, uniqueIdentifier);
+ callback->performCallbackWithReturnValue(hasActiveSession, registeredAsNowPlayingApplication, title, duration, elapsedTime, uniqueIdentifier);
}
#endif
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (227278 => 227279)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2018-01-22 02:38:51 UTC (rev 227278)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2018-01-22 03:30:35 UTC (rev 227279)
@@ -297,7 +297,7 @@
#if PLATFORM(COCOA)
typedef GenericCallback<const WebCore::MachSendRight&> MachSendRightCallback;
-typedef GenericCallback<bool, String, double, double, uint64_t> NowPlayingInfoCallback;
+typedef GenericCallback<bool, bool, String, double, double, uint64_t> NowPlayingInfoCallback;
#endif
class WebPageProxy : public API::ObjectImpl<API::Object::Type::Page>
@@ -1120,7 +1120,7 @@
#if PLATFORM(COCOA)
void requestActiveNowPlayingSessionInfo(Ref<NowPlayingInfoCallback>&&);
- void nowPlayingInfoCallback(bool, const String&, double, double, uint64_t, CallbackID);
+ void nowPlayingInfoCallback(bool, bool, const String&, double, double, uint64_t, CallbackID);
#endif
#if ENABLE(MEDIA_SESSION)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (227278 => 227279)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2018-01-22 02:38:51 UTC (rev 227278)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2018-01-22 03:30:35 UTC (rev 227279)
@@ -201,7 +201,7 @@
#endif
#if PLATFORM(COCOA)
MachSendRightCallback(WebCore::MachSendRight sendRight, WebKit::CallbackID callbackID)
- NowPlayingInfoCallback(bool active, String title, double duration, double elapsedTime, uint64_t uniqueIdentifier, WebKit::CallbackID callbackID)
+ NowPlayingInfoCallback(bool active, bool registeredAsNowPlayingApplication, String title, double duration, double elapsedTime, uint64_t uniqueIdentifier, WebKit::CallbackID callbackID)
#endif
PageScaleFactorDidChange(double scaleFactor)
Modified: trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm (227278 => 227279)
--- trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm 2018-01-22 02:38:51 UTC (rev 227278)
+++ trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm 2018-01-22 03:30:35 UTC (rev 227279)
@@ -48,6 +48,7 @@
double duration = NAN;
double elapsedTime = NAN;
uint64_t uniqueIdentifier = 0;
+ bool registeredAsNowPlayingApplication = false;
if (auto* sharedManager = WebCore::PlatformMediaSessionManager::sharedManagerIfExists()) {
hasActiveSession = sharedManager->hasActiveNowPlayingSession();
title = sharedManager->lastUpdatedNowPlayingTitle();
@@ -54,9 +55,10 @@
duration = sharedManager->lastUpdatedNowPlayingDuration();
elapsedTime = sharedManager->lastUpdatedNowPlayingElapsedTime();
uniqueIdentifier = sharedManager->lastUpdatedNowPlayingInfoUniqueIdentifier();
+ registeredAsNowPlayingApplication = sharedManager->registeredAsNowPlayingApplication();
}
- send(Messages::WebPageProxy::NowPlayingInfoCallback(hasActiveSession, title, duration, elapsedTime, uniqueIdentifier, callbackID));
+ send(Messages::WebPageProxy::NowPlayingInfoCallback(hasActiveSession, registeredAsNowPlayingApplication, title, duration, elapsedTime, uniqueIdentifier, callbackID));
}
} // namespace WebKit
Modified: trunk/Tools/ChangeLog (227278 => 227279)
--- trunk/Tools/ChangeLog 2018-01-22 02:38:51 UTC (rev 227278)
+++ trunk/Tools/ChangeLog 2018-01-22 03:30:35 UTC (rev 227279)
@@ -1,3 +1,16 @@
+2018-01-21 Eric Carlson <[email protected]>
+
+ Resign NowPlaying status when no media element is eligible
+ https://bugs.webkit.org/show_bug.cgi?id=181914
+ <rdar://problem/35294116>
+
+ Reviewed by Jer Noble.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/NowPlayingControlsTests.mm:
+ (-[NowPlayingTestWebView hasActiveNowPlayingSession]):
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/Tests/WebKitCocoa/large-video-test-now-playing.html:
+
2018-01-21 Aakash Jain <[email protected]>
Fix broken unit-tests after r227192
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/NowPlayingControlsTests.mm (227278 => 227279)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/NowPlayingControlsTests.mm 2018-01-22 02:38:51 UTC (rev 227278)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/NowPlayingControlsTests.mm 2018-01-22 03:30:35 UTC (rev 227279)
@@ -35,6 +35,7 @@
@interface NowPlayingTestWebView : TestWKWebView
@property (nonatomic, readonly) BOOL hasActiveNowPlayingSession;
+@property (nonatomic, readonly) BOOL registeredAsNowPlayingApplication;
@property (readonly) NSString *lastUpdatedTitle;
@property (readonly) double lastUpdatedDuration;
@property (readonly) double lastUpdatedElapsedTime;
@@ -44,13 +45,15 @@
@implementation NowPlayingTestWebView {
bool _receivedNowPlayingInfoResponse;
BOOL _hasActiveNowPlayingSession;
+ BOOL _registeredAsNowPlayingApplication;
}
- (BOOL)hasActiveNowPlayingSession
{
_receivedNowPlayingInfoResponse = false;
- auto completionHandler = [retainedSelf = retainPtr(self), self](BOOL active, NSString *title, double duration, double elapsedTime, NSInteger uniqueIdentifier) {
+ auto completionHandler = [retainedSelf = retainPtr(self), self](BOOL active, BOOL registeredAsNowPlayingApplication, NSString *title, double duration, double elapsedTime, NSInteger uniqueIdentifier) {
_hasActiveNowPlayingSession = active;
+ _registeredAsNowPlayingApplication = registeredAsNowPlayingApplication;
_lastUpdatedTitle = [title copy];
_lastUpdatedDuration = duration;
_lastUpdatedElapsedTime = elapsedTime;
@@ -185,6 +188,31 @@
ASSERT_TRUE(isnan(webView.get().lastUpdatedElapsedTime));
ASSERT_TRUE(!webView.get().lastUniqueIdentifier);
}
+
+TEST(NowPlayingControlsTests, NowPlayingControlsCheckRegistered)
+{
+ WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
+ configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
+ auto webView = adoptNS([[NowPlayingTestWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration]);
+ [webView loadTestPageNamed:@"large-video-test-now-playing"];
+ [webView waitForMessage:@"playing"];
+ [webView setWindowVisible:NO];
+ [webView.get().window resignKeyWindow];
+
+ [webView expectHasActiveNowPlayingSession:YES];
+ ASSERT_TRUE(webView.get().registeredAsNowPlayingApplication);
+
+ [webView stringByEvaluatingJavaScript:@"pause()"];
+ [webView waitForMessage:@"paused"];
+ [webView expectHasActiveNowPlayingSession:YES];
+ ASSERT_TRUE(webView.get().registeredAsNowPlayingApplication);
+
+ auto result = [webView stringByEvaluatingJavaScript:@"removeVideoElement()"];
+ ASSERT_STREQ("<null>", result.UTF8String);
+ [webView expectHasActiveNowPlayingSession:NO];
+ ASSERT_FALSE(webView.get().registeredAsNowPlayingApplication);
+}
+
#endif // PLATFORM(MAC)
#if PLATFORM(IOS)
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/large-video-test-now-playing.html (227278 => 227279)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/large-video-test-now-playing.html 2018-01-22 02:38:51 UTC (rev 227278)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/large-video-test-now-playing.html 2018-01-22 03:30:35 UTC (rev 227279)
@@ -8,6 +8,12 @@
position: absolute;
}
+ button {
+ top: 320px;
+ left: 20px;
+ position: absolute;
+ }
+
body {
margin: 0;
}
@@ -25,9 +31,30 @@
function mousedown() {
document.querySelector("video").muted = true;
}
+
+ function removeVideoElement() {
+ document.body.removeChild(document.querySelector("video"));
+ return document.querySelector("video");
+ }
+
+ function pause() {
+ document.querySelector("video").pause();
+ }
+
+ function stopped() {
+ setTimeout(function() {
+ try {
+ window.webkit.messageHandlers.testHandler.postMessage("paused");
+ } catch(e) {
+ console.debug(`error: ${e}`);
+ }
+ }, 0);
+ }
+
</script>
</head>
<body>
- <video autoplay title="foo" _onmousedown_=mousedown() _onplaying_=playing()><source src=""
+ <video autoplay title="foo" _onmousedown_=mousedown() _onplaying_=playing() _onpause_=stopped()><source src=""
+ <button _onclick_="console.log(removeVideoElement())">Stop!</button>
</body>
<html>