зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1627999 - part4 : listen to the playback change from the event source. r=bryce
This patch will do : - listen to the playback change from the event source directly The advantage of doing so : - more close to the real situation because the event source is where we decide the information that should be displayed the virtual control interface Differential Revision: https://phabricator.services.mozilla.com/D72498
This commit is contained in:
Родитель
96b2a42335
Коммит
fb72912836
|
@ -102,6 +102,12 @@ void MediaControlKeysManager::SetPlaybackState(
|
|||
}
|
||||
mPlaybackState = aState;
|
||||
LOG_INFO("playbackState=%s", ToMediaSessionPlaybackStateStr(mPlaybackState));
|
||||
if (StaticPrefs::media_mediacontrol_testingevents_enabled()) {
|
||||
if (nsCOMPtr<nsIObserverService> obs = services::GetObserverService()) {
|
||||
obs->NotifyObservers(nullptr, "media-displayed-playback-changed",
|
||||
nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MediaSessionPlaybackState MediaControlKeysManager::GetPlaybackState() const {
|
||||
|
|
|
@ -317,12 +317,6 @@ void MediaControlService::ControllerManager::MainControllerPlaybackStateChanged(
|
|||
MediaSessionPlaybackState aState) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
mSource->SetPlaybackState(aState);
|
||||
if (StaticPrefs::media_mediacontrol_testingevents_enabled()) {
|
||||
if (nsCOMPtr<nsIObserverService> obs = services::GetObserverService()) {
|
||||
obs->NotifyObservers(nullptr, "main-media-controller-playback-changed",
|
||||
nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MediaControlService::ControllerManager::MainControllerMetadataChanged(
|
||||
|
|
|
@ -56,7 +56,7 @@ add_task(async function testPlayPause() {
|
|||
* The following are helper functions.
|
||||
*/
|
||||
function generateMediaControlKeyEvent(event) {
|
||||
const playbackStateChanged = waitUntilMainMediaControllerPlaybackChanged();
|
||||
const playbackStateChanged = waitUntilDisplayedPlaybackChanged();
|
||||
ChromeUtils.generateMediaControlKeysTestEvent(event);
|
||||
return playbackStateChanged;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ async function createTabAndLoad(url, inputWindow = null) {
|
|||
* and change its playback state.
|
||||
*/
|
||||
function generateMediaControlKeyEvent(event) {
|
||||
const playbackStateChanged = waitUntilMainMediaControllerPlaybackChanged();
|
||||
const playbackStateChanged = waitUntilDisplayedPlaybackChanged();
|
||||
ChromeUtils.generateMediaControlKeysTestEvent(event);
|
||||
return playbackStateChanged;
|
||||
}
|
||||
|
@ -59,10 +59,7 @@ function playMedia(tab, elementId) {
|
|||
return video.play();
|
||||
}
|
||||
);
|
||||
return Promise.all([
|
||||
playPromise,
|
||||
waitUntilMainMediaControllerPlaybackChanged(),
|
||||
]);
|
||||
return Promise.all([playPromise, waitUntilDisplayedPlaybackChanged()]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -90,10 +87,7 @@ function pauseMedia(tab, elementId) {
|
|||
video.pause();
|
||||
}
|
||||
);
|
||||
return Promise.all([
|
||||
pausePromise,
|
||||
waitUntilMainMediaControllerPlaybackChanged(),
|
||||
]);
|
||||
return Promise.all([pausePromise, waitUntilDisplayedPlaybackChanged()]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -222,14 +216,14 @@ function isCurrentMetadataEqualTo(metadata) {
|
|||
|
||||
/**
|
||||
* Wait until the main media controller changes its playback state, we would
|
||||
* observe that by listening for `main-media-controller-playback-changed`
|
||||
* observe that by listening for `media-displayed-playback-changed`
|
||||
* notification.
|
||||
*
|
||||
* @return {Promise}
|
||||
* Resolve when observing `main-media-controller-playback-changed`
|
||||
* Resolve when observing `media-displayed-playback-changed`
|
||||
*/
|
||||
function waitUntilMainMediaControllerPlaybackChanged() {
|
||||
return BrowserUtils.promiseObserved("main-media-controller-playback-changed");
|
||||
function waitUntilDisplayedPlaybackChanged() {
|
||||
return BrowserUtils.promiseObserved("media-displayed-playback-changed");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче