Simple Trick - Adding a Play Indicator to the Browser Tab
Join the DZone community and get the full member experience.Join For Free
i'm a soundcloud user and a while ago i noticed they did something cool with their interface - a "play" icon when you are playing music.
if you've ever been jamming out and needed to quickly mute your computer then this is a nice way to see which browser tab is making sound. in fact, the most recent chrome now makes this built in:
in this case the native indicator is on the right. this is especially handy for cases where a site feels that their users are too stupid to know how to play video and use autoplay. (and let's be clear, if you use autoplay, you think your users are idiots. either that or you are just a rude jerk who feels the need to .... ok sorry i'll stop my rant now. ;)
so i knew this was trivial code but i wanted to build my own little example of this - just for the heck of it.
the example above consists of one dom item - a button. on the page load event, i grab a jquery-wrapped pointer to it and a copy of the current page title. then all i need to do is listen for click events to handle playing (or pausing) the audio. to be clear, i didn't bother adding real audio here. to add the play indicator, you simply use the unicode character for it and prepend it to the title. in case you're curious, i googled for "unicode for play symbol" to find the right one .
if you are incredibly bored and want to see this in action, hit the demo link below.
Published at DZone with permission of Raymond Camden, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.