mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-03 02:25:34 +00:00
Bug 1129882 - add mozInterrupt in telephony object. r=baku
This commit is contained in:
parent
b5daced1c2
commit
cbdade4ed8
@ -64,7 +64,9 @@ public:
|
||||
Telephony::Telephony(nsPIDOMWindow* aOwner)
|
||||
: DOMEventTargetHelper(aOwner),
|
||||
mAudioAgentNotify(nsIAudioChannelAgent::AUDIO_AGENT_NOTIFY),
|
||||
mIsAudioStartPlaying(false)
|
||||
mIsAudioStartPlaying(false),
|
||||
mHaveDispatchedInterruptBeginEvent(false),
|
||||
mMuted(AudioChannelService::IsAudioChannelMutedByDefault())
|
||||
{
|
||||
MOZ_ASSERT(aOwner);
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aOwner);
|
||||
@ -690,6 +692,22 @@ Telephony::WindowVolumeChanged(float aVolume, bool aMuted)
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
// These events will be triggered when the telephony is interrupted by other
|
||||
// audio channel.
|
||||
if (mMuted != aMuted) {
|
||||
mMuted = aMuted;
|
||||
// We should not dispatch "mozinterruptend" when the system app initializes
|
||||
// the telephony audio from muted to unmuted at the first time. The event
|
||||
// "mozinterruptend" must be dispatched after the "mozinterruptbegin".
|
||||
if (!mHaveDispatchedInterruptBeginEvent && mMuted) {
|
||||
DispatchTrustedEvent(NS_LITERAL_STRING("mozinterruptbegin"));
|
||||
mHaveDispatchedInterruptBeginEvent = mMuted;
|
||||
} else if (mHaveDispatchedInterruptBeginEvent && !mMuted) {
|
||||
DispatchTrustedEvent(NS_LITERAL_STRING("mozinterruptend"));
|
||||
mHaveDispatchedInterruptBeginEvent = mMuted;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,8 @@ class Telephony final : public DOMEventTargetHelper,
|
||||
|
||||
uint32_t mAudioAgentNotify;
|
||||
bool mIsAudioStartPlaying;
|
||||
bool mHaveDispatchedInterruptBeginEvent;
|
||||
bool mMuted;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
Loading…
Reference in New Issue
Block a user