Open Bug 728046 Opened 12 years ago Updated 4 days ago

Create per-tab volume controls in Firefox

Categories

(Firefox :: Tabbed Browser, enhancement)

x86
All
enhancement

Tracking

()

People

(Reporter: jboriss, Unassigned)

References

(Blocks 2 open bugs)

Details

We've talked about this feature our whole lives and 3 months before birth in the gestation period, but we never knew how to do it.  However, developer Yuan Xulei has created add-on "Muter" (https://addons.mozilla.org/en-US/firefox/addon/muter/?src=cb-dl-updated) for Linux.  I think this is enough reason to look into the possibility of mute-per-tab again.  I'm going to try and reach out to Yuan to work with us, or perhaps a dev can examine this code and see if what he did can be applied across platforms and added to Firefox.  Either way, let's give this the chance to be real - it's one of our most consistently requested features.

If any developer thinks they have an idea on how to implement, please comment or email me and we will make this thing real.
Blocks: 486262
Depends on: 24418
Blocks: 334987, 449336
Depends on: 593897
So uh, FWIW, that addon just lets you mute the entire browser. From poking around through the source, it appears to do all sorts of horrible hooking into system libraries to do it.

But hey, how about I just CC our Chinese colleagues who wrote it!
(In reply to Ted Mielczarek [:ted, :luser] from comment #1)
> So uh, FWIW, that addon just lets you mute the entire browser. 

Damn - right you are.  It's a good start, though.  We could change the scope of this bug to be per browser session rather than per tab.  However, Beltzner notes that if we can find Flash APIs that we can call to, we could send a signal to every flash embed in a DOM tree saying "mute" (see Bug 593897)
I'm the developer of Muter. As Bug 593897(https://bugzilla.mozilla.org/show_bug.cgi?id=593897) mentions, threre is no general method to change plugin volume by tab without NAPI modification. So currently controling a specified tab's volume is difficult. However it is doable to control by tab without plugin.

I agree with Jennifer Morrow that it is feasible to create per browser volume controller rather than per tab. Win7 and lots of latest linux distributions provide  per-process volume controlling API. Vista and WinXP don't provide these APIs, but we could 'hook' into system libraries to do it. The remaining problems is to support Mac OS and other linux systems without per-process volume controlling API. Maybe we can 'hook' them as well.
As a note, some sites do FORCE you to not be able to turn off sounds (Enjin is one for their chat system)
So I need per-tab, not browser.
Blocks: 24418
No longer depends on: 24418
(In reply to Ted Mielczarek [:ted.mielczarek] from comment #1)
> So uh, FWIW, that addon just lets you mute the entire browser. From poking
> around through the source, it appears to do all sorts of horrible hooking
> into system libraries to do it.
> 
> But hey, how about I just CC our Chinese colleagues who wrote it!

Hey Ted, is it likely that we can detect some sources of sound easily, like HTML5 elements?  I'm assuming Flash & the rest will be harder, but starting with indicating the tab creating sound (and allowing the muting of that tab) just for the sound we *can* detect could be a good start on this problem.
Flags: needinfo?(ted)
(In reply to Jennifer Morrow [:Boriss] (Firefox UX) from comment #8)
> Hey Ted, is it likely that we can detect some sources of sound easily, like
> HTML5 elements?  I'm assuming Flash & the rest will be harder, but starting
> with indicating the tab creating sound (and allowing the muting of that tab)
> just for the sound we *can* detect could be a good start on this problem.

Yes, that's almost certainly doable. roc (or someone else who actually works in media) could confirm.
Flags: needinfo?(ted)
I think we should consider leveraging nsIAudioChannelAgent. nsHTMLMediaElement already knows to create an AudioChannelAgent when the right pref is set, and AudioChannelService manages the set of AudioChannelAgents, and it works with e10s already. An AudioChannelAgent can mute the audio. Web Audio doesn't have an AudioChannelAgent but it will need one (as will every other browser audio source).

If we do it that way, we'll need to create a way to associate tabs with AudioChannelAgents. Perhaps we should use the tab's MessageManager so things work with e10s.

Then we'd need to make AudioChannelService run on desktop and build hooks into it so chrome script can monitor/change channel states.
AFAIK bug 923247 gave us the back-end support to do this for the non-plugin case.
Blocks: 486262
Since we're planning for Q1... could we please make this a higher priority?

Seems like support is falling in place (as stated by baku in http://143th.net/post/79292963535/audio-volume-and-mute-per-window-object ) and people are desperate for this feature for obvious reasons in this time and age of lots of open tabs
Flags: needinfo?(gavin.sharp)
I think fixing this for the non-plugin case would help a lot of people and be a useful feature.
We have support for doing this for HTML audio, but not for plugin-based audio. I suspect plugin-based audio is still most common on the web (though with Youtube gradually switching over to HTML5 video, this may change). I think introducing this feature without support for plugin-based audio is likely to be very confusing.
Assignee: jboriss → nobody
Flags: needinfo?(gavin.sharp)
No longer blocks: 334987
FWIW the Gecko bits required to support this for non-plugin audio have landed a long time ago in bug 923247.  In bug 1167690 we are adding an NPAPI API which would let the plugin mute one of its instances, but not change the volume.
WE need per tab volume sites like bandcamp / soundcloud that sadly don't give any in page volume controls. Are any experiments planned that would support this in multi-threaded tab mode?

I find myself wanting this feature a lot lately.

Many YouTube videos are so quiet that I've had to turn windows master volume, and its setting for Firefox, to 100%. This then means various other tabs, notably those with notification (ha!) sounds, ARE NOW VERY LOUD. If I try to remember and change speaker/headphone volume after finishing a known quiet YT channel video, well, I'll often forget. I don't want to mute those tabs, just attenuate the volume to a comfortable level.

This feature would be highly appreciated indeed!

I have found a Chromium extension that does exactly that. It allows to change the volume of a specific tab.

It uses the chrome.tabCapture API built into Chromium. The API executes an extension-provided callback with LocalMediaStream where the extension changes the gain's value.

The C++ code behind this logic is here: https://source.chromium.org/chromium/chromium/src/+/master:out/Debug/gen/chrome/common/extensions/api/tab_capture.cc;bpv=0;bpt=1

This issue was created 8 years ago when we didn't have HTML5 and Flash was still in. I think it should be much easier now than it was back in the ol' days, although I don't know Firefox's source code that well to make the judgement.

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.