зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1571493 - part5 : use 'MediaControlKeysEventHandler' to deliver control keys event. r=chunmin
Use `MediaControlKeysEventHandler` to handle the control keys event, which can always find corresponding controlled media if there are some. Differential Revision: https://phabricator.services.mozilla.com/D57575 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
bdc6a8cae7
Коммит
4bde50109e
|
@ -18,11 +18,7 @@ namespace dom {
|
|||
|
||||
PlaybackController::PlaybackController(BrowsingContext* aContext) {
|
||||
MOZ_ASSERT(aContext);
|
||||
// TODO : Because of bug 1593826, now we can't ganrantee that we always have
|
||||
// the outer window. In the ideal situation, we should always provide a
|
||||
// correct browsing context which has an outer window, this would be fixed in
|
||||
// bug 1593826.
|
||||
mWindow = aContext->GetDOMWindow();
|
||||
mBC = aContext;
|
||||
}
|
||||
|
||||
void PlaybackController::Play() {
|
||||
|
@ -40,18 +36,22 @@ void PlaybackController::Play() {
|
|||
*/
|
||||
// Our default behavior is to play all media elements within this window and
|
||||
// its children.
|
||||
if (mWindow) {
|
||||
LOG("Handle 'play' in default behavior");
|
||||
mWindow->SetMediaSuspend(nsISuspendedTypes::NONE_SUSPENDED);
|
||||
RefPtr<ContentControlKeyEventReceiver> receiver =
|
||||
ContentControlKeyEventReceiver::Get(mBC);
|
||||
if (receiver) {
|
||||
receiver->OnKeyPressed(MediaControlKeysEvent::ePlay);
|
||||
}
|
||||
};
|
||||
|
||||
void PlaybackController::Pause() {
|
||||
// TODO : same as Play(), we would provide default action handling if current
|
||||
// media session doesn't have an action handler.
|
||||
if (mWindow) {
|
||||
LOG("Handle 'pause' in default behavior");
|
||||
mWindow->SetMediaSuspend(nsISuspendedTypes::SUSPENDED_PAUSE_DISPOSABLE);
|
||||
RefPtr<ContentControlKeyEventReceiver> receiver =
|
||||
ContentControlKeyEventReceiver::Get(mBC);
|
||||
if (receiver) {
|
||||
receiver->OnKeyPressed(MediaControlKeysEvent::ePause);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,9 +83,11 @@ void PlaybackController::SkipAd() {
|
|||
void PlaybackController::Stop() {
|
||||
// TODO : same as Play(), we would provide default action handling if current
|
||||
// media session doesn't have an action handler.
|
||||
if (mWindow) {
|
||||
LOG("Handle 'stop' in default behavior");
|
||||
mWindow->SetMediaSuspend(nsISuspendedTypes::SUSPENDED_STOP_DISPOSABLE);
|
||||
RefPtr<ContentControlKeyEventReceiver> receiver =
|
||||
ContentControlKeyEventReceiver::Get(mBC);
|
||||
if (receiver) {
|
||||
receiver->OnKeyPressed(MediaControlKeysEvent::eStop);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ class MOZ_STACK_CLASS PlaybackController {
|
|||
void SeekTo();
|
||||
|
||||
private:
|
||||
RefPtr<nsPIDOMWindowOuter> mWindow;
|
||||
RefPtr<BrowsingContext> mBC;
|
||||
};
|
||||
|
||||
class MediaActionHandler {
|
||||
|
|
Загрузка…
Ссылка в новой задаче