mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1188487 - Add API to BrowserElement to mute and set volume. r=fabrice
It's already possible to get mute/volume at the audio channel level, but this adds it at the iframe level so that audio channels can be created and destroyed and the setting will be preserved.
This commit is contained in:
parent
acbc7d7d5d
commit
ea89e3d80b
@ -222,6 +222,11 @@ BrowserElementChild.prototype = {
|
||||
"send-touch-event": this._recvSendTouchEvent,
|
||||
"get-can-go-back": this._recvCanGoBack,
|
||||
"get-can-go-forward": this._recvCanGoForward,
|
||||
"mute": this._recvMute.bind(this),
|
||||
"unmute": this._recvUnmute.bind(this),
|
||||
"get-muted": this._recvGetMuted.bind(this),
|
||||
"set-volume": this._recvSetVolume.bind(this),
|
||||
"get-volume": this._recvGetVolume.bind(this),
|
||||
"go-back": this._recvGoBack,
|
||||
"go-forward": this._recvGoForward,
|
||||
"reload": this._recvReload,
|
||||
@ -1300,6 +1305,32 @@ BrowserElementChild.prototype = {
|
||||
});
|
||||
},
|
||||
|
||||
_recvMute: function(data) {
|
||||
this._windowUtils.audioMuted = true;
|
||||
},
|
||||
|
||||
_recvUnmute: function(data) {
|
||||
this._windowUtils.audioMuted = false;
|
||||
},
|
||||
|
||||
_recvGetMuted: function(data) {
|
||||
sendAsyncMsg('got-muted', {
|
||||
id: data.json.id,
|
||||
successRv: this._windowUtils.audioMuted
|
||||
});
|
||||
},
|
||||
|
||||
_recvSetVolume: function(data) {
|
||||
this._windowUtils.audioVolume = data.json.volume;
|
||||
},
|
||||
|
||||
_recvGetVolume: function(data) {
|
||||
sendAsyncMsg('got-volume', {
|
||||
id: data.json.id,
|
||||
successRv: this._windowUtils.audioVolume
|
||||
});
|
||||
},
|
||||
|
||||
_recvGoBack: function(data) {
|
||||
try {
|
||||
docShell.QueryInterface(Ci.nsIWebNavigation).goBack();
|
||||
|
@ -184,6 +184,8 @@ BrowserElementParent.prototype = {
|
||||
"got-contentdimensions": this._gotDOMRequestResult,
|
||||
"got-can-go-back": this._gotDOMRequestResult,
|
||||
"got-can-go-forward": this._gotDOMRequestResult,
|
||||
"got-muted": this._gotDOMRequestResult,
|
||||
"got-volume": this._gotDOMRequestResult,
|
||||
"requested-dom-fullscreen": this._requestedDOMFullscreen,
|
||||
"fullscreen-origin-change": this._fullscreenOriginChange,
|
||||
"exit-dom-fullscreen": this._exitDomFullscreen,
|
||||
@ -664,6 +666,22 @@ BrowserElementParent.prototype = {
|
||||
return this._sendAsyncMsg('clear-match');
|
||||
}),
|
||||
|
||||
mute: defineNoReturnMethod(function() {
|
||||
this._sendAsyncMsg('mute');
|
||||
}),
|
||||
|
||||
unmute: defineNoReturnMethod(function() {
|
||||
this._sendAsyncMsg('unmute');
|
||||
}),
|
||||
|
||||
getMuted: defineDOMRequestMethod('get-muted'),
|
||||
|
||||
getVolume: defineDOMRequestMethod('get-volume'),
|
||||
|
||||
setVolume: defineNoReturnMethod(function(volume) {
|
||||
this._sendAsyncMsg('set-volume', {volume});
|
||||
}),
|
||||
|
||||
goBack: defineNoReturnMethod(function() {
|
||||
this._sendAsyncMsg('go-back');
|
||||
}),
|
||||
|
@ -26,7 +26,7 @@ interface nsIBrowserElementNextPaintListener : nsISupports
|
||||
* Interface to the BrowserElementParent implementation. All methods
|
||||
* but setFrameLoader throw when the remote process is dead.
|
||||
*/
|
||||
[scriptable, uuid(26a832d1-9d71-43ef-9d46-9d7c8ec33f00)]
|
||||
[scriptable, uuid(56bd3e12-4a8b-422a-89fc-6dc25aa30aa2)]
|
||||
interface nsIBrowserElementAPI : nsISupports
|
||||
{
|
||||
const long FIND_CASE_SENSITIVE = 0;
|
||||
@ -77,6 +77,13 @@ interface nsIBrowserElementAPI : nsISupports
|
||||
void findNext(in long direction);
|
||||
void clearMatch();
|
||||
|
||||
void mute();
|
||||
void unmute();
|
||||
nsIDOMDOMRequest getMuted();
|
||||
|
||||
void setVolume(in float volume);
|
||||
nsIDOMDOMRequest getVolume();
|
||||
|
||||
void addNextPaintListener(in nsIBrowserElementNextPaintListener listener);
|
||||
void removeNextPaintListener(in nsIBrowserElementNextPaintListener listener);
|
||||
|
||||
|
@ -625,6 +625,79 @@ nsBrowserElement::GetAllowedAudioChannels(
|
||||
aAudioChannels.AppendElements(mBrowserElementAudioChannels);
|
||||
}
|
||||
|
||||
already_AddRefed<DOMRequest>
|
||||
nsBrowserElement::GetMuted(ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
|
||||
NS_ENSURE_TRUE(IsNotWidgetOrThrow(aRv), nullptr);
|
||||
|
||||
nsCOMPtr<nsIDOMDOMRequest> req;
|
||||
nsresult rv = mBrowserElementAPI->GetMuted(getter_AddRefs(req));
|
||||
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return req.forget().downcast<DOMRequest>();
|
||||
}
|
||||
|
||||
void
|
||||
nsBrowserElement::Mute(ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
|
||||
NS_ENSURE_TRUE_VOID(IsNotWidgetOrThrow(aRv));
|
||||
|
||||
nsresult rv = mBrowserElementAPI->Mute();
|
||||
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsBrowserElement::Unmute(ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
|
||||
NS_ENSURE_TRUE_VOID(IsNotWidgetOrThrow(aRv));
|
||||
|
||||
nsresult rv = mBrowserElementAPI->Unmute();
|
||||
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<DOMRequest>
|
||||
nsBrowserElement::GetVolume(ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
|
||||
NS_ENSURE_TRUE(IsNotWidgetOrThrow(aRv), nullptr);
|
||||
|
||||
nsCOMPtr<nsIDOMDOMRequest> req;
|
||||
nsresult rv = mBrowserElementAPI->GetVolume(getter_AddRefs(req));
|
||||
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return req.forget().downcast<DOMRequest>();
|
||||
}
|
||||
|
||||
void
|
||||
nsBrowserElement::SetVolume(float aVolume, ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
|
||||
NS_ENSURE_TRUE_VOID(IsNotWidgetOrThrow(aRv));
|
||||
|
||||
nsresult rv = mBrowserElementAPI->SetVolume(aVolume);
|
||||
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsBrowserElement::SetNFCFocus(bool aIsFocus,
|
||||
ErrorResult& aRv)
|
||||
|
@ -76,6 +76,13 @@ public:
|
||||
nsTArray<nsRefPtr<dom::BrowserElementAudioChannel>>& aAudioChannels,
|
||||
ErrorResult& aRv);
|
||||
|
||||
void Mute(ErrorResult& aRv);
|
||||
void Unmute(ErrorResult& aRv);
|
||||
already_AddRefed<dom::DOMRequest> GetMuted(ErrorResult& aRv);
|
||||
|
||||
void SetVolume(float aVolume , ErrorResult& aRv);
|
||||
already_AddRefed<dom::DOMRequest> GetVolume(ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<dom::DOMRequest>
|
||||
GetScreenshot(uint32_t aWidth,
|
||||
uint32_t aHeight,
|
||||
|
Loading…
Reference in New Issue
Block a user