Mediasite.namespace("MediaPlayer"),Mediasite.namespace("MediaPlayer.Views"),Mediasite.MediaPlayer.ModelWindowsMedia=function(n){function rateCheckTimer_tick(){if(t&&t.settings&&t.settings.rate&&t.settings.rate!=o){var n=+new Date;if(n=e*(r[r.length-1]-u)?u=r[0]:f.each(r,function(n,t){if(0>=e*(t-u)&&00&&t.currentMedia.imageSourceWidth>0&&(v=t.currentMedia.imageSourceWidth/t.currentMedia.imageSourceHeight),p={AspectRatio:v,Duration:i.GetDuration(),AudioOnly:t.currentMedia.getItemInfo("MediaType")==="audio",CanChangeSpeed:!isLive(),CanFullScreen:!0,CurrentLanguageIndex:i.GetCurrentAudioLanguageIndex(),Languages:i.GetAudioLanguages(),StreamType:n.streamType,IsMainStream:n.isMainStream},c.UpdateMediaInfo(p),r.fire(u.MediaLoaded,p));break;case"PlayStateChange":switch(o){case Mediasite.Player.MediaState.Playing:i.SetPlaybackRate(ft),i.GetPosition()==0&&i.SetPosition(1),a&&t.controls.currentPosition<2&&(e=+new Date-a.getTime()-1e4),t.controls.audioLanguageCount>1&&UseDefaultAudioLanguage(),startPositionUpdateTimer();break;case Mediasite.Player.MediaState.MediaEnded:r.fire(u.PositionChanged,i.GetDuration());case Mediasite.Player.MediaState.Stopped:stopPositionUpdateTimer(),r.fire(u.PositionChanged,i.GetPosition()),h=0,nt=+new Date,r.fire(u.PositionChanged,0);break;case Mediasite.Player.MediaState.Paused:stopPositionUpdateTimer(),r.fire(u.PositionChanged,i.GetPosition());break;default:stopPositionUpdateTimer()}w.setMediaState(o),r.fire(u.StateChanged,o);break;case"PositionChange":k?k=!1:h=i.GetPosition();break;case"ScriptEvent":o.Type==="MS6"&&(l=parseInt(o.Command,10),isNaN(l)||(e=e||0,s=l-t.controls.currentPosition*1e3,b=Math.abs(s-e),b>=st&&(y.Debug("Correcting WMS Live Offset -- old: "+e+", new: "+s),e=s))),r.fire(u.MediaEvent,o)}}function waitForPlayerInit(){if(!t.settings){setTimeout(waitForPlayerInit,200);return}t.settings.invokeURLs=!1,p===Mediasite.Player.MediaPlayerType.Port25?(OnDSPlayStateChangeEvt=function(n){handleMediaEvent("PlayStateChange",n)},OnDSPositionChangeEvt=function(n,t){handleMediaEvent("PositionChange",{newPosition:n,oldPosition:t})},OnDSOpenStateChangeEvt=function(n){handleMediaEvent("OpenStateChange",n)},OnDSScriptCommandEvt=function(n,t){handleMediaEvent("ScriptEvent",{Type:n,Command:t})},OnDSMediaErrorEvt=function(){handleMediaError()}):p===Mediasite.Player.MediaPlayerType.WindowsMedia&&t.attachWmpEvent&&(t.attachWmpEvent("OpenStateChange",function(n){handleMediaEvent("OpenStateChange",n)}),t.attachWmpEvent("PlayStateChange",function(n){handleMediaEvent("PlayStateChange",n)}),t.attachWmpEvent("PositionChange",function(n){handleMediaEvent("PositionChange",n)}),t.attachWmpEvent("ScriptCommand",function(n,t){handleMediaEvent("ScriptEvent",{Type:n,Command:t})}),t.attachWmpEvent("MediaError",function(){handleMediaError()})),t.URL=b,i.SetVolume(d),d===0&&(t.settings.mute=!0)}function isLive(){return!!a}var f=jQuery,i=this,tt,t,b,ot=1,l=n.playbackRates,et=3e3,vt=1e4,h=0,k=!1,lt=-2e3,st=500,ut=!1,d=100,a,e=0,w=new Mediasite.MediaPlayer.LiveMediaOpenReconnector,c,rt,ft=1,wt=Mediasite.GetQueryParam("wmstimecorrection")==="false",y=Mediasite.Logging.LoggerFactory("Media WindowsMedia:"+n.streamType,{separator:"\n"}),v=null,g=200,at=null,ht=100,o=1,nt=0,yt=300,ct={position:0,savedAt:0},pt={position:0,savedAt:0},r=new Mediasite.Player.EventBundle,u=Mediasite.MediaPlayer.ModelEvent,s=n.disableVolume==undefined?!1:n.disableVolume,p,it;this.GetMediaWrapper=function(){return rt},this.SupportsPlayAsVideo=function(){return!1},this.AddEventHandler=function(n,t){r.addHandler(n,t)},p=n.mediaPlayerType,at=setInterval(rateCheckTimer_tick,ht),this.SetupMediaElement=function(i){c=f.extend(new Mediasite.MediaPlayer.BaseView,new it(n)),tt=c.CreateMediaElement(),rt=c.Wrapper,t=tt.get(0);for(var e=0;e=0&&n0?t.controls.pause():i.Stop()},this.Play=function(){ut===!0?window.location.reload():(t.controls.play(),t.settings.rate!=o&&(t.settings.rate=o))},this.Stop=function(){t.controls.stop()},this.GetPosition=function(){var i=t.controls.currentPosition*1e3+e,n;return h>0&&(n=i-h,lt.2?this.SetVolume(this.GetVolume()-20):this.SetVolume(0))},this.ToggleMute=function(){s||(i.IsMuted()?i.UnMute():i.Mute())},this.Mute=function(){t.settings.mute=!0,i.IsMuted()&&r.fire(u.VolumeChanged,0)},this.UnMute=function(){s||(t.settings.mute=!1,i.GetVolume()===0?this.SetVolume(50):r.fire(u.VolumeChanged,Math.round(i.GetVolume())))},this.IsMuted=function(){return t.settings.mute},this.TogglePlayPause=function(){t.playState===Mediasite.Player.MediaState.Playing?i.Pause():i.Play()},this.SetPlaybackRate=function(n){ft=n,t&&(t.settings.rate=n)},this.GetPlaybackRate=function(){return t.settings.rate},this.GetCurrentAudioLanguageIndex=function(){try{return t.controls.currentAudioLanguageIndex}catch(n){return 0}},this.GetAudioLanguages=function(){var n,u=1,r,i;try{u=t.controls.audioLanguageCount}catch(f){}if(u>1){for(r=[],n=0;nif (typeof arguments !== "undefined") {document.getElementById("'+n+'").fireWmpEvent("'+t+'", arguments);}<\/script>'}var r="MediaElement",i,t;this.Wrapper=undefined,this.CreateMediaElement=function(){var e,u;return n.mediaContainer.find(".MediaWrapper").remove(),e=f('
').appendTo(n.mediaContainer),this.Wrapper=e,n.mediaPlayerType===Mediasite.Player.MediaPlayerType.Port25?f('').css("width",n.width).css("height",n.height).appendTo(e):(e.append(makeWmpScripts(r)),u=document.createElement("OBJECT"),u.appendChild(makeParam("windowlessVideo","true")),u.appendChild(makeParam("uiMode","none")),u.appendChild(makeParam("enableContextMenu",n.enableContextMenu)),u.appendChild(makeParam("stretchToFit","true")),n.height&&n.width&&(u.setAttribute("height",n.height),u.setAttribute("width",n.width)),u.setAttribute("id",r),u.setAttribute("classid","clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6"),e.get(0).appendChild(u),t(u),i=f(u),f(u))},this.UpdateMediaInfo=function(n){n.AudioOnly&&i.css("height","0px")},t=function(n){var t={};n=f(n).get(0),n.attachWmpEvent=function(n,i){t[n]=t[n]||f.Callbacks(),t[n].add(i)},n.fireWmpEvent=function(n,i){t[n]&&t[n].fire&&t[n].fire.apply(window,i)}}}}