diff --git a/dom/media/mediasession/MediaSession.cpp b/dom/media/mediasession/MediaSession.cpp index ea632c61d203..761ea255e4a6 100644 --- a/dom/media/mediasession/MediaSession.cpp +++ b/dom/media/mediasession/MediaSession.cpp @@ -96,21 +96,19 @@ void MediaSession::DispatchNotifyHandler( const MediaSessionActionDetails& aDetails) : mozilla::Runnable("MediaSession::DispatchNotifyHandler"), mSession(aSession), - mAction(aDetails.mAction) {} + mDetails(aDetails) {} MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHOD Run() override { if (RefPtr handler = - mSession->GetActionHandler(mAction)) { - MediaSessionActionDetails details; - details.mAction = mAction; - handler->Call(details); + mSession->GetActionHandler(mDetails.mAction)) { + handler->Call(mDetails); } return NS_OK; } private: RefPtr mSession; - MediaSessionAction mAction; + MediaSessionActionDetails mDetails; }; RefPtr runnable = new Runnable(this, aDetails); diff --git a/dom/media/mediasession/test/test_setactionhandler.html b/dom/media/mediasession/test/test_setactionhandler.html index f41d5658ae73..92fa6444852c 100644 --- a/dom/media/mediasession/test/test_setactionhandler.html +++ b/dom/media/mediasession/test/test_setactionhandler.html @@ -13,6 +13,8 @@ SimpleTest.waitForExplicitFinish(); const ACTIONS = [ "play", "pause", + "seekbackward", + "seekforward", "previoustrack", "nexttrack", "stop", @@ -55,6 +57,9 @@ function generateAction(action) { function generateActionDetails(action) { let details = { action }; + if (action == "seekbackward" || action == "seekforward") { + details.seekOffset = 3.14159; + } return details; } diff --git a/dom/webidl/MediaSession.webidl b/dom/webidl/MediaSession.webidl index c13096edc591..9df8e72e73b7 100644 --- a/dom/webidl/MediaSession.webidl +++ b/dom/webidl/MediaSession.webidl @@ -13,10 +13,12 @@ enum MediaSessionPlaybackState { "playing" }; -// TODO: Implement the missing seek* (bug 1580623) and skipad (bug 1582569) actions +// TODO: Implement the missing seekto (bug 1621403) and skipad (bug 1582569) actions enum MediaSessionAction { "play", "pause", + "seekbackward", + "seekforward", "previoustrack", "nexttrack", "stop", @@ -68,6 +70,9 @@ dictionary MediaImage { dictionary MediaSessionActionDetails { required MediaSessionAction action; + // Merge MediaSessionSeekActionDetails here: + // https://github.com/w3c/mediasession/issues/234 + double seekOffset; }; // TODO: Implement MediaPositionState (bug 1582509) diff --git a/testing/web-platform/meta/mediasession/setactionhandler.html.ini b/testing/web-platform/meta/mediasession/setactionhandler.html.ini index 57ec81cba051..17488f285533 100644 --- a/testing/web-platform/meta/mediasession/setactionhandler.html.ini +++ b/testing/web-platform/meta/mediasession/setactionhandler.html.ini @@ -1,5 +1,4 @@ prefs: [dom.media.mediasession.enabled:true] -[setactionhandler.html] # Bug 1580623 +[setactionhandler.html] # Bug 1621403 [Test that setActionHandler() can be executed for supported actions] expected: FAIL -