Adding an audio play indicator to your page's tab with JavaScript
weblogs.asp.net
weblogs.asp.net
[Edit - and it's already gone in the time it took to write this]
I've been using this pattern on http://player.fm for some time now. I agree it's best to just "use the force" of the DOM and base the title symbol on the actual media element's state. Some additional points to consider:
* Another option is to also show a paused or stop state. I did that for a while using a black square character (■), but it looks ugly when people bookmark the page. The same thing happens when bookmarking pages with the play symbol, but that's rarer and at least people have a way to turn it off (ie pause the track).
* Instead of using the title, you could also use a favicon. Although I've been promoting dynamic favicons since I discovered the technique [1], I actually think title is better for this purpose. Why? It lets you retain the actual favicon, it's more portable, it's become more standard. Favicon can be good for more dynamic properties like Scott Schiller's graphic equalizer favicon demo (which I can't find now).
* It works fine with Flash if you use a Flash-compatible JS library like SoundManager or jPlayer.
* It should absolutely be a standard browser feature, but the reason it wasn't is because of the Flash runtime. It presented a black box to browsers so they couldn't actually determine if playback was happening. It's been documented in these bug [2] [3]. It's become less critical as HTML5 media has become more dominant, and I think Chrome and Adobe teams have managed the detection more feasible with Flash.
1. http://softwareas.com/dynamic-favicons
I'm still going to do a lot of messaging around the recording state in the page itself, though, because, I'm not actually recording the whole time that the media stream is connected - I just have it connected the whole time so that I don't need to re-request permission to record.
Chrome will indicate when sound is playing right now if you add "–enable-audible-notifications" to the commandline (easier done on Windows than MacOSX) and even works for sound coming from Flash plug-ins. Of course since it requires a commandline to work, there are likely some issues associated with it (but it has worked fine for me.)
Once this feature no longer requires a commandline, this idea will still be useful for people who use other browsers.
$('a').bind("mousemove", function(event){
document.title = document.title.replace("\u25B6","")
$("audio").each(function(index) {
if(!this.paused) {
document.title = "\u25B6 " + document.title.replace("\u25B6 ","")
return false;
}
})
});Still a great idea, though animating it (there are a few unicode music symbols you could probably cycle through) would make it even better.
The audio player appears almost immediately, but doesn't actually work correctly for ~15 seconds.