Closed Bug 593897 Opened 14 years ago Closed 9 years ago

add API to mute plugin audio

Categories

(Core Graveyard :: Plug-ins, defect)

x86
Windows 7
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1167690

People

(Reporter: wdeng, Unassigned)

References

(Blocks 2 open bugs)

Details

I am DengWei working in Mozillaonline Beijing office.
I am opening this bug for a feature request of Firefox on Windows system.
In China a couple of Firefox's  major competitors have sound mute button on their browser, like Sogou, Maxthon for example.
It is very popular function and well adapted in China. We also got a few request of this feature for Firefox user.
Not sure how difficult to get this feature added into our new release.
Thanks and best regards,
Component: XPCOM → Video/Audio
QA Contact: xpcom → video.audio
This wouldn't mute sound from plugins like flash. (the plugin mute is a dupe and probably impossible to fix)
I have studied the case how sogou and mathon did. When mathon is launched, it loads a dll named Exmute.dll. In the dll, it can hook windows sdk api ,for example, playsound(), when the process invoke playsound, in fact, it invoke their own function, maybe named myOwnPlaySound(). In myOwnPlaySound() function, it can check the  state of playing sound, if nomal, it will invoke sdk playSound() function, if mute, return immediately.
Is that enough to mute flash?  The PlaySound API is pretty primitive; that would probably catch a number of sound effects type sounds, but any more complex playback (e.g. as part of a movie) would still make it through.  Still, this would likely cover most of the annoying ad cases.

We already have a Dll hook mechanism via the DllInterceptor, and flash is already out of process, so we could easily hook the entire process.   However, ideally we'd want to be able to mute by tab and to know which tab is actually making noise; this would require correlating a particular PlaySound call with a particular plugin.  If Flash does this on a thread it creates, this is impossible; but if it does it in response to a npapi event, then it's entirely doable -- just would need to set some global before making the npapi call and unsetting it after each call that the playsound wrapper can check.
Component: Video/Audio → Plug-ins
QA Contact: video.audio → plugins
Summary: How to mute firefox → add API to mute plugin audio
There are many APIs to play sound, PlaySound, DirectSound APIs and so on, maybe we have to hook all the APIs which can play sound. We want to mute the browser only (all the tabs) but having no influence on any other applications. 
Users mute browser not only for ads but when listening music, watching videos with browser in office,our boss is coming, users need to mute browser as soon as possible, when leaders left, they will open the sound again, all users need do is clicking "mute" button twice. Maybe this is the most cases.
If play sound in another thread or process, we have to inject into the thread or process, that violate the security rules, and we'd better not do it that way but only hook our firefox.exe and plugin-container.exe.
Maybe we can study further, how many kinds of players ?Which are the most popular players? How do they play sound?  Which API do they invoke? How to mute them and so on...
I think even being able to mute flash would be a big step, but given the many APIs, it's likely to be tricky.  PlaySound is easy -- you just don't make the call if the browser is muted.  But the other APIs are more complicated (e.g. a streaming API) where we'd need to manage volume on a channel or similar.
We should add NPAPI for this via the plugin-futures list.
But possibly we should trap sound APIs to deal with existing plugins, as well.
Looks like flash is calling waveOutWrite to play sound, this can be easily blocked to mute flash.

I can't see any way of determining what tab it relates to though.
Maybe a global control to mute everything in the entire browser is enough here.
Blocks: 728046
Blocks: 486262
Blocks: 24418
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → DUPLICATE
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.