зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1896774 - Expose length in MPRIS metadata r=media-playback-reviewers,alwu,frontend-codestyle-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D212940
This commit is contained in:
Родитель
698806aee4
Коммит
f4fd19f638
|
@ -1532,7 +1532,7 @@ const rollouts = [
|
|||
"dom/media/autoplay/test/mochitest/file_autoplay_policy_activation_window.html",
|
||||
"dom/media/autoplay/test/mochitest/test_autoplay_policy_permission.html",
|
||||
"dom/media/doctor/test/browser/browser_decoderDoctor.js",
|
||||
"dom/media/mediasession/test/file_trigger_actionhanlder_window.html",
|
||||
"dom/media/mediasession/test/file_trigger_actionhandler_window.html",
|
||||
"dom/media/test/browser/browser_telemetry_video_hardware_decoding_support.js",
|
||||
"dom/media/test/file_access_controls.html",
|
||||
"dom/media/test/manifest.js",
|
||||
|
|
|
@ -51,12 +51,13 @@ add_task(async function testSeekRelative() {
|
|||
info(`start media`);
|
||||
await playMedia(tab, testVideoId);
|
||||
|
||||
const seekoffset = 5;
|
||||
let seekoffset = 5;
|
||||
info(`seek forward ${seekoffset} seconds`);
|
||||
await PerformSeekRelative(tab, "seekforward", {
|
||||
seekOffset: seekoffset,
|
||||
});
|
||||
|
||||
seekoffset = 4;
|
||||
info(`seek backward ${seekoffset} seconds`);
|
||||
await PerformSeekRelative(tab, "seekbackward", {
|
||||
seekOffset: seekoffset,
|
||||
|
@ -104,7 +105,7 @@ async function PerformSeekTo(tab, seekDetails) {
|
|||
[testVideoId],
|
||||
Id => {
|
||||
const video = content.document.getElementById(Id);
|
||||
return new Promise(r => (video.onseeked = r()));
|
||||
return new Promise(r => (video.onseeked = () => r()));
|
||||
}
|
||||
);
|
||||
const { seekTime, fastSeek } = seekDetails;
|
||||
|
@ -127,7 +128,7 @@ async function PerformSeekRelative(tab, mode, seekDetails) {
|
|||
is(seekOffset, details.seekOffset, "Get correct seekoffset");
|
||||
|
||||
content.document.getElementById(Id).currentTime +=
|
||||
mode == "seekForward" ? seekOffset : -seekOffset;
|
||||
mode == "seekforward" ? seekOffset : -seekOffset;
|
||||
});
|
||||
}
|
||||
);
|
||||
|
@ -136,7 +137,7 @@ async function PerformSeekRelative(tab, mode, seekDetails) {
|
|||
[testVideoId],
|
||||
Id => {
|
||||
const video = content.document.getElementById(Id);
|
||||
return new Promise(r => (video.onseeked = r()));
|
||||
return new Promise(r => (video.onseeked = () => r()));
|
||||
}
|
||||
);
|
||||
const { seekOffset } = seekDetails;
|
||||
|
|
|
@ -140,10 +140,10 @@ void MediaSession::SetActionHandler(MediaSessionAction aAction,
|
|||
// this information to the chrome process in order to run the media session
|
||||
// actions update algorithm.
|
||||
// https://w3c.github.io/mediasession/#supported-media-session-actions
|
||||
RefPtr<MediaSessionActionHandler>& hanlder = mActionHandlers[aAction];
|
||||
if (!hanlder && aHandler) {
|
||||
RefPtr<MediaSessionActionHandler>& handler = mActionHandlers[aAction];
|
||||
if (!handler && aHandler) {
|
||||
NotifyEnableSupportedAction(aAction);
|
||||
} else if (hanlder && !aHandler) {
|
||||
} else if (handler && !aHandler) {
|
||||
NotifyDisableSupportedAction(aAction);
|
||||
}
|
||||
mActionHandlers[aAction] = aHandler;
|
||||
|
|
|
@ -67,7 +67,7 @@ async function createSession({shouldCreateFrom, origin}) {
|
|||
const frame = document.getElementById("childFrame");
|
||||
const originURL = origin == "same-origin"
|
||||
? "http://mochi.test:8888" : "http://example.org";
|
||||
frame.src = originURL + "/tests/dom/media/mediasession/test/file_trigger_actionhanlder_frame.html";
|
||||
frame.src = originURL + "/tests/dom/media/mediasession/test/file_trigger_actionhandler_frame.html";
|
||||
await new Promise(r => frame.onload = r);
|
||||
}
|
||||
|
|
@ -4,11 +4,11 @@ tags = "mediasession mediacontrol"
|
|||
|
||||
support-files = [
|
||||
"../../test/gizmo.mp4",
|
||||
"file_trigger_actionhanlder_frame.html",
|
||||
"file_trigger_actionhanlder_window.html",
|
||||
"file_trigger_actionhandler_frame.html",
|
||||
"file_trigger_actionhandler_window.html",
|
||||
"MediaSessionTestUtils.js",
|
||||
]
|
||||
|
||||
["test_setactionhandler.html"]
|
||||
|
||||
["test_trigger_actionhanlder.html"]
|
||||
["test_trigger_actionhandler.html"]
|
||||
|
|
|
@ -19,6 +19,8 @@ const ACTIONS = [
|
|||
"nexttrack",
|
||||
"skipad",
|
||||
"seekto",
|
||||
"seekforward",
|
||||
"seekbackward",
|
||||
"stop",
|
||||
];
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ SpecialPowers.pushPrefEnv({"set": [
|
|||
async function startTest() {
|
||||
for (const testCase of testCases) {
|
||||
info(`- loading test '${testCase.name}' in a new window -`);
|
||||
const testURL = "file_trigger_actionhanlder_window.html";
|
||||
const testURL = "file_trigger_actionhandler_window.html";
|
||||
const testWindow = window.open(testURL, "", "width=500,height=500");
|
||||
await new Promise(r => testWindow.onload = r);
|
||||
|
|
@ -142,6 +142,8 @@ static inline Maybe<dom::MediaControlKey> GetPairedKey(Property aProperty) {
|
|||
return Some(dom::MediaControlKey::Play);
|
||||
case Property::eCanPause:
|
||||
return Some(dom::MediaControlKey::Pause);
|
||||
case Property::eCanSeek:
|
||||
return Some(dom::MediaControlKey::Seekto);
|
||||
default:
|
||||
return Nothing();
|
||||
}
|
||||
|
@ -213,13 +215,13 @@ static GVariant* HandleGetProperty(GDBusConnection* aConnection,
|
|||
return g_variant_new_boolean(false);
|
||||
// Play/Pause would be blocked if CanControl is false
|
||||
case Property::eCanControl:
|
||||
case Property::eCanSeek:
|
||||
return g_variant_new_boolean(true);
|
||||
case Property::eCanRaise:
|
||||
case Property::eCanGoNext:
|
||||
case Property::eCanGoPrevious:
|
||||
case Property::eCanPlay:
|
||||
case Property::eCanPause:
|
||||
case Property::eCanSeek:
|
||||
Maybe<dom::MediaControlKey> key = GetPairedKey(property.value());
|
||||
MOZ_ASSERT(key.isSome());
|
||||
return g_variant_new_boolean(handler->IsMediaKeySupported(key.value()));
|
||||
|
@ -844,6 +846,14 @@ GVariant* MPRISServiceHandler::GetMetadataAsGVariant() const {
|
|||
g_variant_new_string(static_cast<const gchar*>(
|
||||
mMPRISMetadata.mArtUrl.get())));
|
||||
}
|
||||
if (mPositionState.isSome()) {
|
||||
CheckedInt64 length =
|
||||
CheckedInt64((int64_t)mPositionState.value().mDuration) * 1000000;
|
||||
if (length.isValid()) {
|
||||
g_variant_builder_add(&builder, "{sv}", "mpris:length",
|
||||
g_variant_new_int64(length.value()));
|
||||
}
|
||||
}
|
||||
|
||||
return g_variant_builder_end(&builder);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче