define(["events","playbackManager","dom","browser","Modernizr","css!./iconosd","material-icons"],function(events,playbackManager,dom,browser,Modernizr){"use strict";var currentPlayer,osdElement,iconElement,progressElement,enableAnimation,hideTimeout;function onHideComplete(e){e.target===e.currentTarget&&this.classList.contains("iconOsd-hidden")&&this.classList.add("hide")}function clearHideTimeout(){hideTimeout&&(clearTimeout(hideTimeout),hideTimeout=null)}function hideOsd(){clearHideTimeout();var elem=osdElement;elem&&(enableAnimation?(elem.offsetWidth,elem.classList.add("iconOsd-hidden")):onHideComplete.call(elem))}function onVolumeChanged(e){var elem,isMuted,volume;(elem=osdElement)||(enableAnimation=Modernizr.csstransitions,(elem=document.createElement("div")).classList.add("hide"),elem.classList.add("iconOsd"),elem.classList.add("iconOsd-hidden"),elem.classList.add("volumeOsd"),elem.innerHTML='<i class="md-icon iconOsdIcon">&#xE050;</i><div class="iconOsdProgressOuter"><div class="iconOsdProgressInner"></div></div>',iconElement=elem.querySelector("i"),progressElement=elem.querySelector(".iconOsdProgressInner"),document.body.appendChild(elem),osdElement=elem,dom.addEventListener(elem,dom.whichTransitionEvent(),onHideComplete,{passive:!0})),isMuted=this.isMuted(),volume=this.getVolume(),iconElement&&(iconElement.innerHTML=isMuted?"&#xE04F;":"&#xE050;"),progressElement&&(progressElement.style.width=(volume||0)+"%"),function(){clearHideTimeout();var elem=osdElement;elem.classList.remove("hide"),elem.offsetWidth,elem.classList.remove("iconOsd-hidden"),hideTimeout=setTimeout(hideOsd,3e3)}()}function bindToPlayer(player){player!==currentPlayer&&(function(){var player=currentPlayer;player&&(events.off(player,"volumechange",onVolumeChanged),events.off(player,"playbackstop",hideOsd),currentPlayer=null)}(),(currentPlayer=player)&&(hideOsd(),events.on(player,"volumechange",onVolumeChanged),events.on(player,"playbackstop",hideOsd)))}events.on(playbackManager,"playerchange",function(){bindToPlayer(playbackManager.getCurrentPlayer())}),bindToPlayer(playbackManager.getCurrentPlayer())});