"Noisy Tabs" in Google Chrome- Detecting if sound is playing - javascript

Google Chrome recently introduced the feature that allows users to tell what tab is making that "Noisy sound". What i'm interested in finding out is if this new feature allows chrome extensions to detect if a tab is making a sound.
There is no documentation of any similar feature on the chrome.tabs developer page. Is there a way that you would be able to detect if a sound is playing (Without taking a "guess" based off of the content of the page i.e if the page contains mp3 or video content)

necromancer here ...
It's now possible in Chrome 45 :
https://developer.chrome.com/extensions/tabs
boolean (optional) audible
Since Chrome 45. Warning: this is the current Beta channel. Learn more.
Whether the tab has produced sound over the past couple of seconds

Related

How do mobile websites pause videos when other apps start playing audio?

Some mobile sites, like YouTube and Twitch, will pause html <video> elements if other apps (like Spotify, or a podcast player that puts media controls in the notifications) start to play audio.
Interestingly, these don't just take audio focus - they also stop playing if they can't obtain it. As an example, I'm using firefox for android, so I tried disabling its ability to take audio focus with adb:
cmd appops set org.mozilla.firefox TAKE_AUDIO_FOCUS ignore
But now, videos just immediately pause, since it can't pause the other audio source.
How do the sites detect this? I attached a debugger to my phone and looked through the docs but I didn't see anything in either place.
I'm not sure about how this specific flag "TAKE_AUDIO_FOCUS" is interpretted, but modern Android focus management is based on "requesting" (not taking) audio focus. Apps would request it and either get it immediately or listen for updates from the AudioManager as to whether they got it. Similarly they will get updates when someone else requests (and then subsequently receives) focus, and they should react accordingly (i.e. pause/duck themselves). Presumably the apps you mention have asked for audioFocus and were denied it and then hadn't received focus yet, so they just chose to stay paused rather than start playing audio/video and blare out over the app that hadn't released focus yet.
source: https://developer.android.com/guide/topics/media-apps/audio-focus

Enable chrome extension when a tab is opened matching a url

I am pretty new to Chrome extensions and Javascript so any help will be great. Currently I have an extension that takes the currently playing song on tunein.com and populates links to search for the song on Spotify, YouTube, Google Play Music and Google. GitHub link here for reference. I'm currently enabling the extension when you are actively on the tab where tunein.com is playing but I would like to be able to make it work even when that tab is in the background.
I also worry if this will break my current implementation where I am traversing the DOM to get the name of the song and artwork. A lot of the tutorials I was using to develop this have mainly focused on the activeTab. From my cursory research I would set a flag in localStorage and do a check when a new tab is opened but I'm not sure how to access the DOM of a tab in the background or if that is even possible.
Any help would be greatly appreciated!

Chrome auto tab discarding disable java script?

Chrome implement new feature which is called auto tab discarding through this feature enable user when user not on the tab that tab will discard and when user re click on that tab chrome auto refresh that tab. here is the link of Article. this is is very good feature But my problem is I'm showing notification when our tab is active in chrome but because of this feature our Tab is discard and not able to show notifications anymore.
My Question is :- How to Disable this feature or there is any way to keep my tab active or any way to prevent that from discarding?
Users can switch off automatic tab discarding by setting the respective flag in Chrome using this link: chrome://flags/#automatic-tab-discarding
But every page with states depending on user input do have the same problem like yours. Usually, you can prevent unloading a page with handling the onbeforeunload event in JavaScript. Unfortunately, Google does not prevent a solution for this on all systems, despite many users had problems with this feature already in the experimental phase, as you can read in the user comments:
https://developers.google.com/web/updates/2015/09/tab-discarding
For ChomeOS, the problem seams to be fixed:
https://bugs.chromium.org/p/chromium/issues/detail?id=123049
On Android, automatic tab discarding is quite aggressive and prevents using Chrome for applications with significant user input, imho.
On Windows, automatic tab discarding only starts if the available memory is low.
Sorry for not coming up with a proper solution here (I'd be really happy to have one) - I did extensive research and this is all I could find.

How to bypass Chrome disabling autoplay of video's in background tabs

my friends and I are making a website that acts like a radio station called Musare with playlists of YouTube videos that play after each other.
Recently Chrome introduced a new 'feature' that automatically disables autoplaying of videos in background tabs with no option to turn this off. This breaks our site because users don't want to keep going back to the site to start a song. This also broke other big sites, like YouTube playlists, Facebook chat notification sound and a lot of music sharing sites.
By now, a lot of sites have found solutions to bypass this, like dubtrack.fm, YouTube, Facebook and probably some other sites as well.
There is someone working on making an option for it at https://codereview.chromium.org/1414853003/, but that might take weeks or even months for it to be in the main Google Chrome.
If anyone knows how to bypass this, please let me know.
Thanks in advance :)
Already tried:
Starting another video before the current one ends - no success
Messing around with the Player Variables - no success
Other things probably - no success
Extra notes:
We are using the YouTube API. We use YT.Player and the youtubePlayer.loadVideoById(id)
SoundCloud streaming works fine with SC.Stream.
The source code for our project is at https://github.com/Musare/Musare
So I have found out how to bypass it finally, after many hours of trying and researching.
If you just initialize the iframe player of YouTube by using the YT.Player constructor, you can then just use the player variable and use yourPlayerVariable.loadVideoById(id).
You have to first go to the tab for it to start, but after that it will be able to load and play video's without you having to go back to the tab. If you remove and re-add the iframe, you will have to go back for it to start again.

Inserting an icon to the right of the page title in Chrome

I recently noticed that when viewing YouTube videos in Chrome, it inserts a fancy looking audio icon into the tab when the video is playing. However the icon is not part of the actual page title, but instead appears to the right of the page title, like this:
Notice how the actual page title is truncated due to the tab length and fades out on the right hand side.
How is this accomplished? Is there an HTML or JavaScript property that can insert this icon there? What other icons, if any, can be used?
Note, I realize this is not cross-browser property since it doesn't work for FireFox. I'm wondering only about Chrome/Chromium.
we don't need any script to do that. It's a feature developed by Chrome developer. Chrome will automatically display the icon when there is an audio or video playing.
More info.
Chrome added the icon to any tab making sound. The idea is that when an Ad or music begins randomly playing, it needs to be easy to find and kill.
There is no HTML, JS, etc. that adds the icons. Anything that creates sound will place the sound icon on the tab in chrome -- while the tab is making sound.
The only similar icon I know of is the Chrome Cast icon, but that requires the Chrome Cast extension.
Chrome does insert this icon, if I play video on other site, then it looks like

Categories

Resources