зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1654045 - part2 : add 'onactivated/ondeactivated' event handlers and 'isActive' on the media control webidl interface. r=chunmin
Add an event handler `onactivated/ondeactivated` and a readonly attribute `isActive` on the media control webidl interface, and they can be used in testing and the future plan of supporting media hub. Differential Revision: https://phabricator.services.mozilla.com/D85229
This commit is contained in:
Родитель
a3ed6de802
Коммит
4f35b1bd20
|
@ -27,9 +27,13 @@ enum MediaControlKey {
|
|||
*/
|
||||
[Exposed=Window, ChromeOnly]
|
||||
interface MediaController : EventTarget {
|
||||
readonly attribute boolean isActive;
|
||||
|
||||
[Frozen, Cached, Pure]
|
||||
readonly attribute sequence<MediaControlKey> supportedKeys;
|
||||
|
||||
attribute EventHandler onactivated;
|
||||
attribute EventHandler ondeactivated;
|
||||
attribute EventHandler onpositionstatechange;
|
||||
attribute EventHandler onsupportedkeyschange;
|
||||
|
||||
|
|
|
@ -148,6 +148,8 @@ bool MediaController::IsAudible() const { return IsMediaAudible(); }
|
|||
|
||||
bool MediaController::IsPlaying() const { return IsMediaPlaying(); }
|
||||
|
||||
bool MediaController::IsActive() const { return mIsActive; };
|
||||
|
||||
void MediaController::UpdateMediaControlActionToContentMediaIfNeeded(
|
||||
const MediaControlAction& aAction) {
|
||||
// If the controller isn't active or it has been shutdown, we don't need to
|
||||
|
@ -306,6 +308,7 @@ void MediaController::Activate() {
|
|||
LOG("Activate");
|
||||
mIsActive = service->RegisterActiveMediaController(this);
|
||||
MOZ_ASSERT(mIsActive, "Fail to register controller!");
|
||||
DispatchAsyncEvent(u"activated"_ns);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -318,6 +321,7 @@ void MediaController::Deactivate() {
|
|||
LOG("Deactivate");
|
||||
mIsActive = !service->UnregisterActiveMediaController(this);
|
||||
MOZ_ASSERT(!mIsActive, "Fail to unregister controller!");
|
||||
DispatchAsyncEvent(u"deactivated"_ns);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ class IMediaController {
|
|||
virtual uint64_t Id() const = 0;
|
||||
virtual bool IsAudible() const = 0;
|
||||
virtual bool IsPlaying() const = 0;
|
||||
virtual bool IsActive() const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -87,6 +88,8 @@ class MediaController final : public DOMEventTargetHelper,
|
|||
JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
void GetSupportedKeys(nsTArray<MediaControlKey>& aRetVal) const;
|
||||
IMPL_EVENT_HANDLER(activated);
|
||||
IMPL_EVENT_HANDLER(deactivated);
|
||||
IMPL_EVENT_HANDLER(supportedkeyschange);
|
||||
IMPL_EVENT_HANDLER(positionstatechange);
|
||||
|
||||
|
@ -105,6 +108,7 @@ class MediaController final : public DOMEventTargetHelper,
|
|||
uint64_t Id() const override;
|
||||
bool IsAudible() const override;
|
||||
bool IsPlaying() const override;
|
||||
bool IsActive() const override;
|
||||
|
||||
// IMediaInfoUpdater's methods
|
||||
void NotifyMediaPlaybackChanged(uint64_t aBrowsingContextId,
|
||||
|
|
|
@ -2383,6 +2383,8 @@ STATIC_ATOMS = [
|
|||
Atom("onboundary", "onboundary"),
|
||||
|
||||
# Media Controller
|
||||
Atom("onactivated", "onactivated"),
|
||||
Atom("ondeactivated", "ondeactivated"),
|
||||
Atom("onpositionstatechange", "onpositionstatechange"),
|
||||
Atom("onsupportedkeyschange", "onsupportedkeyschange"),
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче