From a8e1c51812b3d3ea1e7a4fe88d771cc3afef7039 Mon Sep 17 00:00:00 2001 From: "jan.prochazka" Date: Thu, 29 Sep 2016 21:02:13 +0200 Subject: [PATCH] Event fix --- dist/js/julia-player.js | 5 ++--- dist/js/julia-player.min.js | 2 +- src/js/julia-events.js | 4 ++-- src/js/julia-ui.js | 1 - 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/dist/js/julia-player.js b/dist/js/julia-player.js index 0e536d5..fe05d74 100644 --- a/dist/js/julia-player.js +++ b/dist/js/julia-player.js @@ -556,7 +556,6 @@ Julia.prototype._Ui = function(origin) origin.env.model.toolbar.hide(); origin.env.model.buttons.bigPlay.hide(); origin.Ui.state(origin.env.model.preloader, '', 'on'); - origin.env.instance.insertAfter(origin.env.element); origin.env.fullscreenFrame = document.querySelector('#julia-player-'+origin.env.ID); @@ -1176,10 +1175,10 @@ Julia.prototype._Events = function(origin) // Video position origin.env.api.ontimeupdate = function(e) { + currentTimeReadable = origin.Timecode.toHuman( origin.env.api.currentTime.toFixed(2) ); + if(origin.env.seeking === false) { - currentTimeReadable = origin.Timecode.toHuman( origin.env.api.currentTime.toFixed(2) ); - origin.env.model.sliders.progress.update( origin.Timecode.toPercents( origin.env.api.currentTime ) ); origin.Ui.panel( diff --git a/dist/js/julia-player.min.js b/dist/js/julia-player.min.js index 8b6ae2b..91a0373 100644 --- a/dist/js/julia-player.min.js +++ b/dist/js/julia-player.min.js @@ -1 +1 @@ -var Julia=function(e){var n=this;e="undefined"==typeof e?{}:e;var t="julia";dir=$('script[src*="julia-player"], script[src*="julia-base"]').attr("src"),name=dir.split("/").pop(),t=dir.replace("/js/"+name,""),t=t.replace("src","dist");var o=Math.floor(1e7*Math.random()+1);return n.options={source:!1,autoplay:!1,volume:25,element:$("video"),muted:!1,width:512,height:288,debug:!1,debugPlayback:!1,force:!1,live:!1,responsive:!0,pauseOnBlur:!1,dimensions:[[1920,1080],[1280,720],[960,540],[640,360],[512,288]],pauseOnClick:!1,poster:"",hlsConfig:{debug:!1},dashConfig:{},suggest:[],suggestLimit:4,suggestTimeout:1e4,themePath:t+"/css/themes",pluginPath:t+"/js/lib",require:[],theme:"default",i18n:{liveText:"Live"},onTime:{},triggerHls:{},triggerDash:{},onPlay:!1,onPause:!1,onStop:!1,onPosition:!1,onSuggest:!1},n.env={element:n.options.element,instance:{},fullscreenFrame:!1,ID:o,api:{},model:{container:"",shield:"",toolbar:"",poster:"",suggest:"",preloader:"",buttons:{bigPlay:"",play:"",sound:"",fullscreen:""},ranges:{volume:"",progress:""},sliders:{volume:"",progress:""},panels:{live:"",currentTime:"",duration:""},labels:{goto:""},menus:{}},isLive:!1,hls:!1,dash:!1,canPlayMedia:"",canPlayMediaString:"",isHls:!1,isDash:!1,useHlsLib:!1,source:"",duration:0,apiOk:!1,onTimeRised:[],seeking:!1,dimensions:{width:0,height:0},started:!1,publicApi:{},suggestPointer:0,suggestClicked:!1,progressStep:.01},n.Base={},n.Base.debug=function(e){if(n.options.debug===!0&&window.console)for(d in e)console.log(" - [instance: "+n.env.ID+"] "+d+" ["+typeof e[d]+"]",e[d])},n.Base.stats=function(){return{isDash:n.env.isDash,isHls:n.env.isHls,useHlsLib:n.env.useHlsLib,live:n.env.isLive,canPlayMediaString:n.env.canPlayMediaString,canPlayMedia:n.env.canPlayMedia}},n.Ui=new n._Ui(n),n.Api=new n._Api(n),n.Support=new n._Support(n),n.Controls=new n._Controls(n),n.Timecode=new n._Timecode(n),n.Events=new n._Events(n),n.Persist=new n._Persist(n),n.Fullscreen=new n._Fullscreen(n),n.Callback=new n._Callback(n),n.Suggest=new n._Suggest(n),n.Inject=new n._Inject(n),n.Require=new n._Require(n),n.Boot=new n._Boot(n),n.Loader=new n._Loader(n),$.extend(!0,n.options,e),n.options.debug===!0&&window.console&&console.info("=== Julia console debug start, instance "+n.env.ID+" ==="),n.Require.css([t+"/css/julia-player.min.css",n.options.themePath+"/"+n.options.theme+"/julia.css"]),n.Require.js(n.options.require),$("body").on("julia.plugins-loaded julia.no-plugins","#julia-player-"+n.env.ID,function(e){"plugins-loaded"==e.namespace?n.Base.debug({"Required plugins loaded":[e.type,e.namespace]}):n.Base.debug({"No plugins required":[e.type,e.namespace]}),n.Ui.state(n.env.model.preloader,"on",""),n.env.model.buttons.bigPlay.show(),n.options.autoplay===!0&&n.Support.isMobile()===!1&&n.env.model.buttons.bigPlay.click()}),$("body").on("julia.ui-ready","#julia-player-"+n.env.ID,function(e){n.env.model.sliders.progress=new n._Slider(n,{element:$("#julia-toolbar-"+n.env.ID+">div.julia-progress>input.julia-range"),eventRise:"progress-change"}),n.env.model.sliders.progress.init(),n.env.model.sliders.volume=new n._Slider(n,{element:$("#julia-toolbar-"+n.env.ID+">div.julia-volume>input.julia-range"),eventRise:"volume-change"}),n.env.model.sliders.volume.init(),n.Support.resize(),n.Events.ui(),n.Events.native(),volume=n.Persist.get("julia-player-volume"),muted=n.Persist.get("julia-player-muted"),"undefined"!=typeof volume&&volume.length>0&&(n.options.volume=parseInt(volume),(n.options.volume>100||n.options.volume<0)&&(n.options.volume=25)),"undefined"!=typeof muted&&muted.length>0&&(n.options.muted="false"!=muted)}),n.Boot.run(),n.env.publicApi={options:n.options,shield:n.env.model.shield,toolbar:n.env.model.toolbar,api:n.env.api,ID:n.env.ID,dimensions:n.env.dimensions,Controls:n.Controls,Extend:n.Base.extend,Support:n.Support,Timecode:n.Timecode,Require:n.Require,Inject:n.Inject,stats:n.Base.stats},n.env.publicApi};Julia.prototype._Api=function(e){var n=this;n.create=function(){$("#julia-api-"+e.env.ID).remove(),apiElement=$(''),e.env.instance.prepend(apiElement),e.env.api=document.getElementById("julia-api-"+e.env.ID),e.env.api.controls=!1,e.env.apiOk=!0,"function"==typeof makeVideoPlayableInline&&makeVideoPlayableInline(e.env.api),e.Base.debug({apiId:e.env.ID,api:e.env.api})},n.source=function(){protoSource=e.env.element.prop("src")?e.env.element.prop("src"):e.env.element.find("source").prop("src"),e.env.source=e.options.source&&e.options.source.length>0?e.options.source:protoSource,e.env.isHls=e.env.source.indexOf(".m3u8")!=-1,"hls"===e.options.force&&(e.env.isHls=!0),e.env.isDash=!e.env.source.indexOf(".mpd")&&e.env.source.indexOf(".ism")!=-1,"dash"===e.options.force&&(e.env.isDash=!0),e.Base.debug({"Api source isHls":e.env.isHls,"Api source isDash":e.env.isDash,Source:e.env.source}),e.env.model.poster=e.options.poster&&e.options.poster.length>0?e.options.poster:e.env.element.prop("poster"),e.Ui.posterSet()},n.allowStart=function(n){e.Controls.press("setDuration",{duration:e.Timecode.toHuman(e.env.duration)}),e.options.muted===!0?e.Controls.press("sound-off"):(e.Controls.press("sound-on"),e.Controls.press("volume",{volume:e.options.volume})),e.Base.debug({eventType:n.type,duration:e.env.api.duration,readyState:e.env.api.readyState})},n.canplaythrough=function(){e.env.started===!1&&(e.env.api.readyState>=3||e.Support.isMobile()===!0&&e.env.api.readyState>=2?e.Api.allowStart({type:"origin.Events.canplaythrough"}):setTimeout(function(){e.Api.canplaythrough()},100))}},Julia.prototype._Ui=function(e){var n=this;n.create=function(){e.env.instance.length>0&&(e.env.instance.remove(),e.env.instance={}),e.env.instance=$('
'),e.env.model.shield=$('
'),e.env.model.preloader=$('
'),e.env.model.suggest=$('
'),e.env.model.toolbar=$('
'),e.env.model.buttons.bigPlay=$(''),e.env.model.buttons.play=$(''),e.env.model.buttons.sound=$(''),e.env.model.buttons.fullscreen=$(''),e.env.model.ranges.volume=$('
'),e.env.model.ranges.progress=$('
'),e.env.model.panels.live=$('
'+e.options.i18n.liveText+"
"),e.env.model.panels.currentTime=$('
00:00:00 / 
'),e.env.model.panels.duration=$('
00:00:00
'),e.env.model.labels.goto=$('
00:00:00
'),e.env.model.shield.append([e.env.model.preloader,e.env.model.buttons.bigPlay]),e.Support.iOS()===!0?e.env.model.toolbar.append([e.env.model.ranges.progress,e.env.model.panels.live,e.env.model.panels.currentTime,e.env.model.panels.duration,e.env.model.buttons.play,e.env.model.buttons.fullscreen,e.env.model.labels.goto]):e.env.model.toolbar.append([e.env.model.ranges.progress,e.env.model.panels.live,e.env.model.panels.currentTime,e.env.model.panels.duration,e.env.model.buttons.play,e.env.model.buttons.sound,e.env.model.ranges.volume,e.env.model.buttons.fullscreen,e.env.model.labels.goto]),e.env.instance.append([e.env.model.shield,e.env.model.suggest,e.env.model.toolbar]),e.env.element.hide(),e.env.model.toolbar.hide(),e.env.model.buttons.bigPlay.hide(),e.Ui.state(e.env.model.preloader,"","on"),e.env.instance.insertAfter(e.env.element),e.env.fullscreenFrame=document.querySelector("#julia-player-"+e.env.ID),n.raiseEvent("julia.ui-ready"),e.Base.debug({playerInstance:e.env.instance})},n.raiseEvent=function(t){setTimeout(function(){1==$("#julia-player-"+e.env.ID).length?$("#julia-player-"+e.env.ID).trigger({type:t}):n.raiseEvent(t)},10)},n.icon=function(e,n,t){e.find("i").removeClass(n).addClass(t)},n.state=function(e,n,t){e.removeClass(n).addClass(t)},n.panel=function(e,n){e.find("span").text(n)},n.posterSet=function(){n.posterUnset(),e.env.model.poster.length>0&&(img=$(''),e.env.model.shield.append(img),e.Base.debug({poster:e.env.model.poster}))},n.posterUnset=function(){e.env.model.shield.find("img").remove()}},Julia.prototype._Slider=function(e,n){var t=this,o=!1,i=navigator.userAgent,s=/chrome/i.exec(i),a=/android/i.exec(i),l="ontouchstart"in window&&!(s&&!a),u=function(e){return e>100?100:e<0?0:Math.round(100*e)/100},r=function(e){return u(e/(t.track.innerWidth()/100))},d=function(e){var n=l===!0?e.originalEvent.touches[0].pageX-t.model.offset().left:e.originalEvent.pageX-t.model.offset().left;return percent=r(n),percent},p=function(e){var n=l===!0?e.originalEvent.touches[0].pageX-t.model.offset().left:e.originalEvent.pageX-t.model.offset().left;return n},c=$('
');return t.model=c.clone(),t.track=t.model.find('[data-julia-slider-component="track"]'),t.handle=t.model.find('[data-julia-slider-component="handle"]'),t.fill=t.model.find('[data-julia-slider-component="fill"]'),t.options={element:{},value:0,originVisible:!1,eventRise:"",overcall:function(){}},$.extend(!0,t.options,n),t.elem="object"==typeof t.options.element?t.options.element:$(t.options.element.toString()),t.value=t.options.value,t.init=function(){["input"].lastIndexOf(t.elem.prop("tagName").toLowerCase())>-1&&(t.value=u(t.elem.val())),t.options.originVisible===!1?t.elem.hide().after(t.model):t.elem.after(t.model),t.slide(t.value,!0)},t.update=function(e){o===!1&&t.slide(e,!0)},t.slide=function(e,n){"undefined"==typeof n&&(n=!1),t.value=u(e);var o=t.track.innerWidth()/100*t.value;t.handle.css({left:o+"px"}),t.fill.css({width:o+2+"px"}),t.respond(e,n)},t.respond=function(n,o){"undefined"==typeof o&&(o=!1),["input"].lastIndexOf(t.elem.prop("tagName").toLowerCase())>-1&&(t.elem.val(t.value),o===!1&&$("#julia-player-"+e.env.ID).trigger({type:"julia."+t.options.eventRise,percent:n})),t.track.innerWidth(t.model.innerWidth()-t.handle.innerWidth())},t.getValue=function(){return t.value},t.sliding=function(){return o},t.fill.on("click ",function(e){t.slide(d(e),!1)}),t.track.on("click",function(e){t.slide(d(e),!1)}),t.model.on("click mouseover mousemove mouseout",function(n){"click"==n.type&&t.slide(d(n),!1),"mouseover"!=n.type&&"mousemove"!=n.type||"progress-change"!=t.options.eventRise||(pos=d(n),pix=p(n),e.Ui.state(e.env.model.labels.goto,"","on"),e.Ui.panel(e.env.model.labels.goto,e.Timecode.toHuman(e.Timecode.toSeconds(pos))),left=pix+"px",border=e.env.model.labels.goto.innerWidth()/2,pixt.model.innerWidth()-border-10&&(left=t.model.innerWidth()-border+"px"),e.env.model.labels.goto.css({left:left,"margin-left":-(e.env.model.labels.goto.innerWidth()/2)+"px"})),"mouseout"==n.type&&"progress-change"==t.options.eventRise&&e.Ui.state(e.env.model.labels.goto,"on","")}),t.model.on("mousedown touchstart",function(e){"touchstart"==e.type&&t.slide(d(e),!1),o=!0}),$(document).on("mouseup touchend",function(e){o=!1}),$(document).on("mousemove touchmove",function(e){o===!0&&t.slide(d(e))}),t},Julia.prototype._Events=function(e){var n=this;n.ui=function(){e.env.model.toolbar.on("contextmenu",function(e){e.preventDefault()}).on("click",".julia-playback.play",function(n){n.preventDefault(),e.Controls.press("play")}).on("click",".julia-playback.pause",function(n){n.preventDefault(),e.Controls.press("pause")}).on("click",".julia-sound.on",function(n){n.preventDefault(),e.Controls.press("sound-off")}).on("click",".julia-sound.off",function(n){n.preventDefault(),e.Controls.press("sound-on")}).on("click",".julia-fullscreen-toggle.on",function(n){n.preventDefault(),e.Controls.press("fullscreen-on")}).on("click",".julia-fullscreen-toggle.off",function(n){n.preventDefault(),e.Controls.press("fullscreen-off")}),e.env.model.shield.on("click contextmenu",".julia-big-play",function(n){n.preventDefault(),n.stopPropagation(),"click"==n.type&&(e.env.started===!1&&(e.Ui.state(e.env.model.preloader,"","on"),e.Loader.init()),e.Controls.press("play"))}),e.env.model.shield.on("dblclick click contextmenu",function(n){n.preventDefault(),n.stopPropagation(),e.options.pauseOnClick===!0&&e.Support.isMobile()===!1&&"click"==n.type&&(e.env.api.paused===!1?e.Controls.press("pause"):e.Controls.press("play")),"dblclick"==n.type&&(e.env.instance.hasClass("julia-fullscreen-on")?e.Controls.press("fullscreen-off"):e.Controls.press("fullscreen-on"))});var n;e.env.instance.on("mousemove touchmove","#julia-shield-"+e.env.ID+", #julia-suggest-"+e.env.ID,function(t){t.preventDefault(),e.env.model.toolbar.addClass("julia-toolbar-visible"),clearTimeout(n),n=setTimeout(function(){e.env.model.toolbar.removeClass("julia-toolbar-visible")},1750)}).on("mouseover mousemove touchmove mouseout","#julia-toolbar-"+e.env.ID+".julia-toolbar-visible",function(t){t.preventDefault(),e.env.model.toolbar.addClass("julia-toolbar-visible"),clearTimeout(n),["mouseout","touchend"].lastIndexOf(t.type.toLowerCase())>-1&&(n=setTimeout(function(n){e.env.model.toolbar.removeClass("julia-toolbar-visible")},1750))}),$("body").on("julia.progress-change","#julia-player-"+e.env.ID,function(n,t){seekTo=e.Timecode.toSeconds(n.percent),seekTo=seekTo>=e.env.duration?e.env.duration:seekTo.toFixed(2),e.Controls.press("goto",{currentTime:seekTo})}),$("body").on("julia.volume-change","#julia-player-"+e.env.ID,function(n,t){e.Controls.press("volume",{volume:n.percent})}),$(window).on("resize",function(){e.Support.resize()})},n.native=function(){e.Support.forceReady()===!0&&e.env.isHls===!0?e.Api.canplaythrough():e.env.api.oncanplaythrough=function(n){e.env.duration=e.env.api.duration,e.env.started===!1&&e.env.api.readyState>=3&&e.Api.allowStart(n)},e.env.api.onplay=function(n){e.Ui.state(e.env.model.buttons.play,"play","pause"),e.Ui.icon(e.env.model.buttons.play,"julia-play","julia-pause"),e.env.model.buttons.bigPlay.hide(),e.Ui.posterUnset(),e.env.model.toolbar.show()},e.env.api.onplaying=function(n){e.Ui.state(e.env.model.buttons.play,"play","pause"),e.Ui.icon(e.env.model.buttons.play,"julia-play","julia-pause"),e.env.model.buttons.bigPlay.hide(),e.env.model.suggest.html(""),e.Ui.state(e.env.model.suggest,"on",""),e.env.model.toolbar.show(),e.Controls.press("setDuration",{duration:e.Timecode.toHuman(e.env.duration)}),e.env.started=!0},e.env.api.onpause=function(n){e.Ui.state(e.env.model.buttons.play,"pause","play"),e.Ui.icon(e.env.model.buttons.play,"julia-pause","julia-play"),setTimeout(function(){e.env.api.paused===!0&&e.env.model.buttons.bigPlay.show()},350)},e.env.api.onerror=function(e){},e.env.api.onemptied=function(e){},e.env.api.onstalled=function(e){},e.env.api.onsuspend=function(e){},e.env.api.ontimeupdate=function(n){e.env.seeking===!1&&(currentTimeReadable=e.Timecode.toHuman(e.env.api.currentTime.toFixed(2)),e.env.model.sliders.progress.update(e.Timecode.toPercents(e.env.api.currentTime)),e.Ui.panel(e.env.model.panels.currentTime,currentTimeReadable),e.Ui.state(e.env.model.preloader,"on","")),e.Callback.onTime(currentTimeReadable,e.env.api.currentTime),e.options.debugPlayback===!0&&e.Base.debug({"duration/current":e.env.duration+"/"+e.env.api.currentTime.toFixed(2)+" > "+currentTimeReadable})},e.env.api.onseeked=function(n){e.env.seeking=!1},e.env.api.onseeking=function(n){e.Ui.state(e.env.model.preloader,"","on"),e.env.seeking=!0},e.env.api.onvolumechange=function(n){e.env.api.muted===!1?e.env.model.sliders.volume.update(100*e.env.api.volume):e.env.model.sliders.volume.update(0)},e.env.api.ondurationchange=function(n){e.env.duration=e.env.api.duration,e.env.started===!1&&(e.env.duration=e.env.api.duration,e.env.seeking=!1,e.Base.debug({duration:e.env.duration,readyState:e.env.api.readyState,started:e.env.started}))},e.env.api.onended=function(n){e.Suggest.run()},$(window).on("blur",function(){e.options.pauseOnBlur===!0&&e.env.api.paused===!1&&e.env.started===!0&&e.Controls.press("pause")})},n.hlsLibEvents=function(){e.env.hls.on(Hls.Events.ERROR,function(n,t){switch(t.details){case Hls.ErrorDetails.MANIFEST_LOAD_ERROR:case Hls.ErrorDetails.MANIFEST_LOAD_TIMEOUT:case Hls.ErrorDetails.MANIFEST_PARSING_ERROR:case Hls.ErrorDetails.LEVEL_LOAD_ERROR:case Hls.ErrorDetails.LEVEL_LOAD_TIMEOUT:case Hls.ErrorDetails.LEVEL_SWITCH_ERROR:case Hls.ErrorDetails.FRAG_LOAD_ERROR:case Hls.ErrorDetails.FRAG_LOOP_LOADING_ERROR:case Hls.ErrorDetails.FRAG_LOAD_TIMEOUT:case Hls.ErrorDetails.FRAG_DECRYPT_ERROR:case Hls.ErrorDetails.FRAG_PARSING_ERROR:case Hls.ErrorDetails.BUFFER_APPEND_ERROR:case Hls.ErrorDetails.BUFFER_APPENDING_ERROR:e.Base.debug({recoveringError:t.details,errorType:t.type,errorFatal:t.fatal,data:t}),t.fatal===!0&&e.env.tries<11}})},n.dashLibEvents=function(){e.env.dash.on(dashjs.MediaPlayer.events,function(n,t){switch(t.details){case dashjs.MediaPlayer.events.ERROR:e.Base.debug({recoveringError:dashjs.MediaPlayer.events.ERROR})}})}},Julia.prototype._Controls=function(e){var n=this;n.press=function(n,t){switch(t=t||{},e.Base.debug({action:n,"action-data":t}),n){case"play":e.options.onPlay!==!1&&e.Callback.fn(e.options.onPlay,t),e.env.model.buttons.bigPlay.hide(),e.env.api.play();break;case"pause":e.options.onPause!==!1&&e.Callback.fn(e.options.onPause,t),e.env.api.pause();break;case"stop":e.options.onStop!==!1&&e.Callback.fn(e.options.onStop,t),e.env.api.pause(),e.env.api.currentTime=0,e.Ui.state(e.env.model.buttons.play,"pause","play"),e.Ui.icon(e.env.model.buttons.play,"julia-pause","julia-play"),e.env.model.buttons.bigPlay.show(),e.env.model.sliders.progress.update(0);break;case"goto":e.Ui.state(e.env.model.preloader,"","on"),e.env.api.currentTime=t.currentTime,e.options.onPosition!==!1&&e.Callback.fn(e.options.onPosition,t);break;case"setDuration":e.Ui.panel(e.env.model.panels.duration,t.duration),e.env.started===!1&&e.env.model.sliders.progress.update(0),e.Base.debug({setDuration:t.duration});break;case"volume":e.options.volume=t.volume,e.env.api.volume=t.volume/100,e.Base.debug({"volume is":e.env.api.volume}),e.env.model.sliders.volume.update(t.volume),t.volume>0?e.Controls.press("sound-on"):e.Controls.press("sound-off");break;case"sound-on":e.env.api.muted=!1,e.options.muted=!1,e.Persist.set("julia-player-volume",e.options.volume,999),e.Persist.set("julia-player-muted",e.options.muted,999),e.Ui.state(e.env.model.buttons.sound,"off","on"),e.Ui.icon(e.env.model.buttons.sound,"julia-sound-off","julia-sound-on");break;case"sound-off":e.env.api.muted=!0,e.options.muted=!0,e.Persist.set("julia-player-volume",e.options.volume,999),e.Persist.set("julia-player-muted",e.options.muted,999),e.Ui.state(e.env.model.buttons.sound,"on","off"),e.Ui.icon(e.env.model.buttons.sound,"julia-sound-on","julia-sound-off");break;case"fullscreen-on":e.Fullscreen.reset(e.env.instance,e.env.model,e.env.api),e.Fullscreen.on(e.env.fullscreenFrame);break;case"fullscreen-off":e.Fullscreen.reset(e.env.instance,e.env.model,e.env.api),e.Fullscreen.off()}}},Julia.prototype._Support=function(e){var n=this;n.aspect=function(e,n){return e>0&&n>0?n/e:0},n.isMobile=function(){return!!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile/i.test(navigator.userAgent)},n.iOS=function(){return!(!/iPad|iPhone|iPod/.test(navigator.userAgent)||window.MSStream)},n.forceReady=function(){return!!/Firefox/i.test(navigator.userAgent)},n.canPlayMedia=function(){var n=document.createElement("video");return n.id="video-cap-test-"+e.env.ID,e.env.canPlayMediaString=n.canPlayType("application/vnd.apple.mpegURL"),$("#video-cap-test"+e.env.ID).remove(),"probably"==e.env.canPlayMediaString||"maybe"==e.env.canPlayMediaString},n.resize=function(){defaultDim=e.env.element.width()?[e.env.element.width(),e.env.element.height()]:[e.options.width,e.options.height],dimensions=e.options.responsive===!0?n.getSize():defaultDim,e.Base.debug({resizeDefaults:defaultDim,resize:dimensions}),e.env.instance.width(dimensions[0]),e.env.instance.height(dimensions[1]),e.env.dimensions.width=dimensions[0],e.env.dimensions.height=dimensions[1],e.env.api.setAttribute("width","100%"),e.env.api.setAttribute("height","100%")},n.getSize=function(){var t=e.env.element.parent().css("display").toLowerCase();"inline"==t&&e.env.element.parent().css({display:"block"});var o=e.env.element.parent().width();for(i in e.options.dimensions){var s=e.options.dimensions[i];if(o>=s[0])return a=0==n.aspect(o)?s[1]/s[0]:n.aspect(e.env.api.videoWidth,e.env.api.videoHeight),dimensions=[s[0],s[0]*a],e.Base.debug({resizePredefined:dimensions}),dimensions}return a=0==n.aspect()?s[1]/s[0]:n.aspect(e.env.api.videoWidth,e.env.api.videoHeight),dimensions=[o,o*a],e.Base.debug({resizeFallback:dimensions}),dimensions}},Julia.prototype._Suggest=function(e){var n=this;n.run=function(){if(e.env.model.suggest.html(""),e.Controls.press("stop"),e.env.suggestClicked=!1,e.options.suggest.length>0){x=0;for(var n in e.options.suggest)if(x0?'':"",suggestItemWidget=$('
'+posterImage+'
'+e.options.suggest[n].title+"
"),suggestItemWidget.on("click",function(t){e.options.onSuggest!==!1&&e.Callback.fn(e.options.onSuggest,e.options.suggest[n]),e.options.muted=e.env.api.muted,e.options.poster=$(this).data("poster"),e.env.suggestClicked=!0,e.env.model.buttons.bigPlay.hide(),e.env.started=!1,e.options.source=$(this).data("source"),e.Api.source(),e.options.autoplay=!0,e.options.live="live"==$(this).data("mode"),e.options.i18n.liveText=$(this).data("live-text"),e.Ui.panel(e.env.model.panels.live,e.options.i18n.liveText),e.Base.debug({suggestRemoveIndex:$(this).data("index"),suggestRemove:$(this).data("source")}),e.options.suggest[$(this).data("index")].played=!0,e.Ui.state(e.env.model.suggest,"on",""),e.env.model.buttons.bigPlay.click()}),e.env.model.suggest.append(suggestItemWidget),x++}x>0&&(e.options.suggestTimeout>0&&e.Support.isMobile()===!1&&setTimeout(function(){e.env.suggestClicked===!1&&e.env.model.suggest.find("div.julia-suggest-item:first").click()},e.options.suggestTimeout),e.Ui.state(e.env.model.suggest,"","on"))}else e.Fullscreen.off();e.Base.debug({Suggest:"raised"})}},Julia.prototype._Fullscreen=function(e){var n=this;n.on=function(n){n.requestFullscreen?n.requestFullscreen():n.msRequestFullscreen?n.msRequestFullscreen():n.mozRequestFullScreen?n.mozRequestFullScreen():n.webkitRequestFullscreen?n.webkitRequestFullscreen():e.Base.debug({fullscreen:"Fullscreen is not supported"})},n.off=function(){document.exitFullscreen?document.exitFullscreen():document.msExitFullscreen?document.msExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()},n.reset=function(n,t,o){$(document).off("webkitfullscreenchange mozfullscreenchange fullscreenchange MSFullscreenChange"),$(document).on("webkitfullscreenchange mozfullscreenchange fullscreenchange MSFullscreenChange",function(i){document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement?(e.Ui.state(n,"julia-fullscreen-off","julia-fullscreen-on"),e.Ui.state(t.buttons.fullscreen,"on","off"),e.Ui.icon(t.buttons.fullscreen,"julia-fullscreen","julia-fullscreen-exit"),e.Support.isMobile()&&(screen.orientation.lock("landscape-primary"),screen.msLockOrientation.lock("landscape-primary"),screen.mozLockOrientation.lock("landscape-primary")),e.Base.debug({"fullscreen on":"#julia-player-"+e.env.ID})):(e.Ui.state(n,"julia-fullscreen-on","julia-fullscreen-off"),e.Ui.state(t.buttons.fullscreen,"off","on"),e.Ui.icon(t.buttons.fullscreen,"julia-fullscreen-exit","julia-fullscreen"),e.Support.isMobile()&&(screen.orientation.unlock(),screen.msLockOrientation.unlock(),screen.mozLockOrientation.unlock()),e.Base.debug({"fullscreen off":"#julia-player-"+e.env.ID})),e.Support.resize(),setTimeout(function(){w=e.env.api.getAttribute("width"),e.env.instance.find(".julia-progress").width(w),e.env.instance.find(".julia-progress .julia-slider-track").width(w),t.sliders.progress.update(e.Timecode.toPercents(o.currentTime))},5)})}},Julia.prototype._Persist=function(e){var n=this;n.set=function(e,n,t){dateObj=new Date,dateObj.setTime(dateObj.getTime()+24*t*60*60*1e3);var o="expires="+dateObj.toUTCString();document.cookie=e+"="+n+"; "+o+"; path=/"},n.get=function(e){for(var e=e+"=",n=document.cookie.split(";"),t=0;t1?parseInt(e[1]):0,h=e.length>2?parseInt(e[3]):0,t=s+60*m+60*h*60,t},n.toHuman=function(e){return e=e.toString().split("."),s=e[0],H=Math.floor(s/3600),M=Math.floor((s-3600*H)/60),S=Math.floor(s-3600*H-60*M),H=("0"+H.toString()).slice(-2),M=("0"+M.toString()).slice(-2),S=("0"+S.toString()).slice(-2),str=H>0?H+":"+M+":"+S:M+":"+S,str}},Julia.prototype._Callback=function(e){var n=this;n.fn=function(n,t){t=t||{},$.inArray(typeof n,["string","function","object"])>-1?("string"==typeof n&&(n=window[n]),n(e.options,e.env,t),e.Base.debug({Callback:typeof n+" raised"})):e.Base.debug({Callback:typeof n+" is not a function, but: "+typeof n})},n.onTime=function(n,t){n in e.options.onTime&&e.env.onTimeRised.indexOf(n)==-1&&(f=e.options.onTime[n],e.env.onTimeRised.push(n),$.inArray(typeof f,["string","function","object"])>-1?("string"==typeof f&&(f=window[f]),f(e.options,e.env,n),e.Base.debug({"Callback onTime":n+" "+typeof f+" raised"})):e.Base.debug({"Callback onTime":n+" "+typeof f+" is not a function, but: "+typeof f}))}},Julia.prototype._Inject=function(e){var n=this;n.source=function(n){$("#julia-player-"+e.env.ID).remove(),e.env.started=!1,$.extend(!0,e.options,n),e.Boot.run(),e.options.live===!0?(e.env.isLive=!0,e.Ui.panel(e.env.model.panels.live,e.options.i18n.liveText),e.Ui.state(e.env.model.toolbar,"","live")):(e.env.isLive=!1,e.Ui.panel(e.env.model.panels.live,""),e.Ui.state(e.env.model.toolbar,"live","")),e.Ui.state(e.env.model.preloader,"on",""),e.options.autoplay===!0&&e.Support.isMobile()===!1?e.env.model.buttons.bigPlay.click():e.env.model.buttons.bigPlay.show()}},Julia.prototype._Require=function(e){var n=this;n.js=function(e){if("string"==typeof e&&(e=[e]),0==e.length)n.raiseEvent("julia.no-plugins");else{var t=e[e.length-1];n.load(e,0,t)}},n.raiseEvent=function(t){setTimeout(function(){1==$("#julia-player-"+e.env.ID).length?$("#julia-player-"+e.env.ID).trigger({type:t}):n.raiseEvent(t)},20)},n.load=function(t,o,i){var s=t[o];e.Base.debug({"Require-js request":s}),$.getScript(s).done(function(){e.Base.debug({"Require-js loaded":s}),i==s?n.raiseEvent("julia.plugins-loaded"):n.load(t,o+1,i)})},n.css=function(e){"string"==typeof e&&(e=[e]);for(i in e)$("head").append($(''))}},Julia.prototype._Boot=function(e){var n=this;n.run=function(){e.Base.debug(e.options),e.env.element=e.options.element;for(i in e.options.suggest)e.options.suggest[i].played=!1;e.env.hls!==!1&&(e.env.hls.destroy(),e.env.hls=!1),e.env.dash!==!1&&(e.env.dash.reset(),e.env.dash=!1),e.Ui.create(),e.Api.source(),e.Api.create()}},Julia.prototype._Loader=function(e){var n=this;n.init=function(){e.env.api.src="",e.env.useHlsLib=!1,e.env.isLive=!1,e.env.canPlayMedia=e.Support.canPlayMedia(),e.env.isHls===!0&&(e.env.useHlsLib=!(e.env.canPlayMedia!==!1||!Hls.isSupported())),e.env.useHlsLib===!0?e.env.hls=new Hls(e.options.hlsConfig):e.env.isDash===!0||(e.env.api.src=e.env.source),e.options.live===!0?(e.env.isLive=!0,e.Ui.state(e.env.model.toolbar,"","live")):(e.env.isLive=!1,e.Ui.state(e.env.model.toolbar,"live","")),e.env.useHlsLib===!0?(e.Events.hlsLibEvents(),e.env.hls.autoLevelCapping=-1,e.env.hls.attachMedia(e.env.api),e.env.hls.loadSource(e.env.source),e.env.hls.on(Hls.Events.MEDIA_ATTACHED,function(n,t){e.env.hls.on(Hls.Events.LEVEL_LOADED,function(e,n){});for(x in e.options.triggerHls)handle=e.options.triggerHls[x],"function"==typeof window[handle]?e.env.hls.on(Hls.Events[x],function(n,t){window[handle](e.env.apiId,n,t)}):e.Base.debug({triggerHlsError:handle+" is not a function"})})):e.env.isDash===!0?(e.env.dash=dashjs.MediaPlayer().create(),e.env.dash.initialize(),e.env.dash.attachView(e.env.api),e.env.dash.attachSource(e.env.source),e.env.dash.setAutoPlay(e.options.autoplay),e.options.debug===!1&&e.env.dash.getDebug().setLogToBrowserConsole(!1),e.Events.dashLibEvents()):e.env.api.load(),e.Ui.state(e.env.model.preloader,"","on"),e.Api.allowStart({type:"origin.Loader"})}},jQuery.fn.julia=function(e){return this.play=function(){$(this).data("julia").Controls.press("play")},this.setOptions=function(e){$.extend(!0,$(this).data("julia").options,e)},this.options=function(){return $(this).data("julia").options},this.source=function(e){$(this).data("julia").Inject.source(e)},this.api=function(){return $(this).data("julia").api},this.pause=function(){$(this).data("julia").Controls.press("pause")},this.stop=function(){$(this).data("julia").Controls.press("stop")},this.goto=function(e){$(this).data("julia").Controls.press("goto",{currentTime:e})},this.mute=function(){$(this).data("julia").api.muted===!1?$(this).data("julia").Controls.press("sound-off"):$(this).data("julia").Controls.press("sound-on")},this.volume=function(e){$(this).data("julia").Controls.press("volume",{volume:e})},this.getID=function(){return $(this).data("julia").ID},this.stats=function(){return $(this).data("julia").stats()},this.each(function(){if(!$(this).data("julia")){e="undefined"==typeof e?{}:e,e.element=$(this);var n=new Julia(e);$(this).data("julia",n)}})}; \ No newline at end of file +var Julia=function(e){var n=this;e="undefined"==typeof e?{}:e;var t="julia";dir=$('script[src*="julia-player"], script[src*="julia-base"]').attr("src"),name=dir.split("/").pop(),t=dir.replace("/js/"+name,""),t=t.replace("src","dist");var o=Math.floor(1e7*Math.random()+1);return n.options={source:!1,autoplay:!1,volume:25,element:$("video"),muted:!1,width:512,height:288,debug:!1,debugPlayback:!1,force:!1,live:!1,responsive:!0,pauseOnBlur:!1,dimensions:[[1920,1080],[1280,720],[960,540],[640,360],[512,288]],pauseOnClick:!1,poster:"",hlsConfig:{debug:!1},dashConfig:{},suggest:[],suggestLimit:4,suggestTimeout:1e4,themePath:t+"/css/themes",pluginPath:t+"/js/lib",require:[],theme:"default",i18n:{liveText:"Live"},onTime:{},triggerHls:{},triggerDash:{},onPlay:!1,onPause:!1,onStop:!1,onPosition:!1,onSuggest:!1},n.env={element:n.options.element,instance:{},fullscreenFrame:!1,ID:o,api:{},model:{container:"",shield:"",toolbar:"",poster:"",suggest:"",preloader:"",buttons:{bigPlay:"",play:"",sound:"",fullscreen:""},ranges:{volume:"",progress:""},sliders:{volume:"",progress:""},panels:{live:"",currentTime:"",duration:""},labels:{goto:""},menus:{}},isLive:!1,hls:!1,dash:!1,canPlayMedia:"",canPlayMediaString:"",isHls:!1,isDash:!1,useHlsLib:!1,source:"",duration:0,apiOk:!1,onTimeRised:[],seeking:!1,dimensions:{width:0,height:0},started:!1,publicApi:{},suggestPointer:0,suggestClicked:!1,progressStep:.01},n.Base={},n.Base.debug=function(e){if(n.options.debug===!0&&window.console)for(d in e)console.log(" - [instance: "+n.env.ID+"] "+d+" ["+typeof e[d]+"]",e[d])},n.Base.stats=function(){return{isDash:n.env.isDash,isHls:n.env.isHls,useHlsLib:n.env.useHlsLib,live:n.env.isLive,canPlayMediaString:n.env.canPlayMediaString,canPlayMedia:n.env.canPlayMedia}},n.Ui=new n._Ui(n),n.Api=new n._Api(n),n.Support=new n._Support(n),n.Controls=new n._Controls(n),n.Timecode=new n._Timecode(n),n.Events=new n._Events(n),n.Persist=new n._Persist(n),n.Fullscreen=new n._Fullscreen(n),n.Callback=new n._Callback(n),n.Suggest=new n._Suggest(n),n.Inject=new n._Inject(n),n.Require=new n._Require(n),n.Boot=new n._Boot(n),n.Loader=new n._Loader(n),$.extend(!0,n.options,e),n.options.debug===!0&&window.console&&console.info("=== Julia console debug start, instance "+n.env.ID+" ==="),n.Require.css([t+"/css/julia-player.min.css",n.options.themePath+"/"+n.options.theme+"/julia.css"]),n.Require.js(n.options.require),$("body").on("julia.plugins-loaded julia.no-plugins","#julia-player-"+n.env.ID,function(e){"plugins-loaded"==e.namespace?n.Base.debug({"Required plugins loaded":[e.type,e.namespace]}):n.Base.debug({"No plugins required":[e.type,e.namespace]}),n.Ui.state(n.env.model.preloader,"on",""),n.env.model.buttons.bigPlay.show(),n.options.autoplay===!0&&n.Support.isMobile()===!1&&n.env.model.buttons.bigPlay.click()}),$("body").on("julia.ui-ready","#julia-player-"+n.env.ID,function(e){n.env.model.sliders.progress=new n._Slider(n,{element:$("#julia-toolbar-"+n.env.ID+">div.julia-progress>input.julia-range"),eventRise:"progress-change"}),n.env.model.sliders.progress.init(),n.env.model.sliders.volume=new n._Slider(n,{element:$("#julia-toolbar-"+n.env.ID+">div.julia-volume>input.julia-range"),eventRise:"volume-change"}),n.env.model.sliders.volume.init(),n.Support.resize(),n.Events.ui(),n.Events.native(),volume=n.Persist.get("julia-player-volume"),muted=n.Persist.get("julia-player-muted"),"undefined"!=typeof volume&&volume.length>0&&(n.options.volume=parseInt(volume),(n.options.volume>100||n.options.volume<0)&&(n.options.volume=25)),"undefined"!=typeof muted&&muted.length>0&&(n.options.muted="false"!=muted)}),n.Boot.run(),n.env.publicApi={options:n.options,shield:n.env.model.shield,toolbar:n.env.model.toolbar,api:n.env.api,ID:n.env.ID,dimensions:n.env.dimensions,Controls:n.Controls,Extend:n.Base.extend,Support:n.Support,Timecode:n.Timecode,Require:n.Require,Inject:n.Inject,stats:n.Base.stats},n.env.publicApi};Julia.prototype._Api=function(e){var n=this;n.create=function(){$("#julia-api-"+e.env.ID).remove(),apiElement=$(''),e.env.instance.prepend(apiElement),e.env.api=document.getElementById("julia-api-"+e.env.ID),e.env.api.controls=!1,e.env.apiOk=!0,"function"==typeof makeVideoPlayableInline&&makeVideoPlayableInline(e.env.api),e.Base.debug({apiId:e.env.ID,api:e.env.api})},n.source=function(){protoSource=e.env.element.prop("src")?e.env.element.prop("src"):e.env.element.find("source").prop("src"),e.env.source=e.options.source&&e.options.source.length>0?e.options.source:protoSource,e.env.isHls=e.env.source.indexOf(".m3u8")!=-1,"hls"===e.options.force&&(e.env.isHls=!0),e.env.isDash=!e.env.source.indexOf(".mpd")&&e.env.source.indexOf(".ism")!=-1,"dash"===e.options.force&&(e.env.isDash=!0),e.Base.debug({"Api source isHls":e.env.isHls,"Api source isDash":e.env.isDash,Source:e.env.source}),e.env.model.poster=e.options.poster&&e.options.poster.length>0?e.options.poster:e.env.element.prop("poster"),e.Ui.posterSet()},n.allowStart=function(n){e.Controls.press("setDuration",{duration:e.Timecode.toHuman(e.env.duration)}),e.options.muted===!0?e.Controls.press("sound-off"):(e.Controls.press("sound-on"),e.Controls.press("volume",{volume:e.options.volume})),e.Base.debug({eventType:n.type,duration:e.env.api.duration,readyState:e.env.api.readyState})},n.canplaythrough=function(){e.env.started===!1&&(e.env.api.readyState>=3||e.Support.isMobile()===!0&&e.env.api.readyState>=2?e.Api.allowStart({type:"origin.Events.canplaythrough"}):setTimeout(function(){e.Api.canplaythrough()},100))}},Julia.prototype._Ui=function(e){var n=this;n.create=function(){e.env.instance.length>0&&(e.env.instance.remove(),e.env.instance={}),e.env.instance=$('
'),e.env.model.shield=$('
'),e.env.model.preloader=$('
'),e.env.model.suggest=$('
'),e.env.model.toolbar=$('
'),e.env.model.buttons.bigPlay=$(''),e.env.model.buttons.play=$(''),e.env.model.buttons.sound=$(''),e.env.model.buttons.fullscreen=$(''),e.env.model.ranges.volume=$('
'),e.env.model.ranges.progress=$('
'),e.env.model.panels.live=$('
'+e.options.i18n.liveText+"
"),e.env.model.panels.currentTime=$('
00:00:00 / 
'),e.env.model.panels.duration=$('
00:00:00
'),e.env.model.labels.goto=$('
00:00:00
'),e.env.model.shield.append([e.env.model.preloader,e.env.model.buttons.bigPlay]),e.Support.iOS()===!0?e.env.model.toolbar.append([e.env.model.ranges.progress,e.env.model.panels.live,e.env.model.panels.currentTime,e.env.model.panels.duration,e.env.model.buttons.play,e.env.model.buttons.fullscreen,e.env.model.labels.goto]):e.env.model.toolbar.append([e.env.model.ranges.progress,e.env.model.panels.live,e.env.model.panels.currentTime,e.env.model.panels.duration,e.env.model.buttons.play,e.env.model.buttons.sound,e.env.model.ranges.volume,e.env.model.buttons.fullscreen,e.env.model.labels.goto]),e.env.instance.append([e.env.model.shield,e.env.model.suggest,e.env.model.toolbar]),e.env.element.hide(),e.env.model.toolbar.hide(),e.env.model.buttons.bigPlay.hide(),e.Ui.state(e.env.model.preloader,"","on"),e.env.instance.insertAfter(e.env.element),e.env.fullscreenFrame=document.querySelector("#julia-player-"+e.env.ID),n.raiseEvent("julia.ui-ready"),e.Base.debug({playerInstance:e.env.instance})},n.raiseEvent=function(t){setTimeout(function(){1==$("#julia-player-"+e.env.ID).length?$("#julia-player-"+e.env.ID).trigger({type:t}):n.raiseEvent(t)},10)},n.icon=function(e,n,t){e.find("i").removeClass(n).addClass(t)},n.state=function(e,n,t){e.removeClass(n).addClass(t)},n.panel=function(e,n){e.find("span").text(n)},n.posterSet=function(){n.posterUnset(),e.env.model.poster.length>0&&(img=$(''),e.env.model.shield.append(img),e.Base.debug({poster:e.env.model.poster}))},n.posterUnset=function(){e.env.model.shield.find("img").remove()}},Julia.prototype._Slider=function(e,n){var t=this,o=!1,i=navigator.userAgent,s=/chrome/i.exec(i),a=/android/i.exec(i),l="ontouchstart"in window&&!(s&&!a),u=function(e){return e>100?100:e<0?0:Math.round(100*e)/100},r=function(e){return u(e/(t.track.innerWidth()/100))},d=function(e){var n=l===!0?e.originalEvent.touches[0].pageX-t.model.offset().left:e.originalEvent.pageX-t.model.offset().left;return percent=r(n),percent},p=function(e){var n=l===!0?e.originalEvent.touches[0].pageX-t.model.offset().left:e.originalEvent.pageX-t.model.offset().left;return n},c=$('
');return t.model=c.clone(),t.track=t.model.find('[data-julia-slider-component="track"]'),t.handle=t.model.find('[data-julia-slider-component="handle"]'),t.fill=t.model.find('[data-julia-slider-component="fill"]'),t.options={element:{},value:0,originVisible:!1,eventRise:"",overcall:function(){}},$.extend(!0,t.options,n),t.elem="object"==typeof t.options.element?t.options.element:$(t.options.element.toString()),t.value=t.options.value,t.init=function(){["input"].lastIndexOf(t.elem.prop("tagName").toLowerCase())>-1&&(t.value=u(t.elem.val())),t.options.originVisible===!1?t.elem.hide().after(t.model):t.elem.after(t.model),t.slide(t.value,!0)},t.update=function(e){o===!1&&t.slide(e,!0)},t.slide=function(e,n){"undefined"==typeof n&&(n=!1),t.value=u(e);var o=t.track.innerWidth()/100*t.value;t.handle.css({left:o+"px"}),t.fill.css({width:o+2+"px"}),t.respond(e,n)},t.respond=function(n,o){"undefined"==typeof o&&(o=!1),["input"].lastIndexOf(t.elem.prop("tagName").toLowerCase())>-1&&(t.elem.val(t.value),o===!1&&$("#julia-player-"+e.env.ID).trigger({type:"julia."+t.options.eventRise,percent:n})),t.track.innerWidth(t.model.innerWidth()-t.handle.innerWidth())},t.getValue=function(){return t.value},t.sliding=function(){return o},t.fill.on("click ",function(e){t.slide(d(e),!1)}),t.track.on("click",function(e){t.slide(d(e),!1)}),t.model.on("click mouseover mousemove mouseout",function(n){"click"==n.type&&t.slide(d(n),!1),"mouseover"!=n.type&&"mousemove"!=n.type||"progress-change"!=t.options.eventRise||(pos=d(n),pix=p(n),e.Ui.state(e.env.model.labels.goto,"","on"),e.Ui.panel(e.env.model.labels.goto,e.Timecode.toHuman(e.Timecode.toSeconds(pos))),left=pix+"px",border=e.env.model.labels.goto.innerWidth()/2,pixt.model.innerWidth()-border-10&&(left=t.model.innerWidth()-border+"px"),e.env.model.labels.goto.css({left:left,"margin-left":-(e.env.model.labels.goto.innerWidth()/2)+"px"})),"mouseout"==n.type&&"progress-change"==t.options.eventRise&&e.Ui.state(e.env.model.labels.goto,"on","")}),t.model.on("mousedown touchstart",function(e){"touchstart"==e.type&&t.slide(d(e),!1),o=!0}),$(document).on("mouseup touchend",function(e){o=!1}),$(document).on("mousemove touchmove",function(e){o===!0&&t.slide(d(e))}),t},Julia.prototype._Events=function(e){var n=this;n.ui=function(){e.env.model.toolbar.on("contextmenu",function(e){e.preventDefault()}).on("click",".julia-playback.play",function(n){n.preventDefault(),e.Controls.press("play")}).on("click",".julia-playback.pause",function(n){n.preventDefault(),e.Controls.press("pause")}).on("click",".julia-sound.on",function(n){n.preventDefault(),e.Controls.press("sound-off")}).on("click",".julia-sound.off",function(n){n.preventDefault(),e.Controls.press("sound-on")}).on("click",".julia-fullscreen-toggle.on",function(n){n.preventDefault(),e.Controls.press("fullscreen-on")}).on("click",".julia-fullscreen-toggle.off",function(n){n.preventDefault(),e.Controls.press("fullscreen-off")}),e.env.model.shield.on("click contextmenu",".julia-big-play",function(n){n.preventDefault(),n.stopPropagation(),"click"==n.type&&(e.env.started===!1&&(e.Ui.state(e.env.model.preloader,"","on"),e.Loader.init()),e.Controls.press("play"))}),e.env.model.shield.on("dblclick click contextmenu",function(n){n.preventDefault(),n.stopPropagation(),e.options.pauseOnClick===!0&&e.Support.isMobile()===!1&&"click"==n.type&&(e.env.api.paused===!1?e.Controls.press("pause"):e.Controls.press("play")),"dblclick"==n.type&&(e.env.instance.hasClass("julia-fullscreen-on")?e.Controls.press("fullscreen-off"):e.Controls.press("fullscreen-on"))});var n;e.env.instance.on("mousemove touchmove","#julia-shield-"+e.env.ID+", #julia-suggest-"+e.env.ID,function(t){t.preventDefault(),e.env.model.toolbar.addClass("julia-toolbar-visible"),clearTimeout(n),n=setTimeout(function(){e.env.model.toolbar.removeClass("julia-toolbar-visible")},1750)}).on("mouseover mousemove touchmove mouseout","#julia-toolbar-"+e.env.ID+".julia-toolbar-visible",function(t){t.preventDefault(),e.env.model.toolbar.addClass("julia-toolbar-visible"),clearTimeout(n),["mouseout","touchend"].lastIndexOf(t.type.toLowerCase())>-1&&(n=setTimeout(function(n){e.env.model.toolbar.removeClass("julia-toolbar-visible")},1750))}),$("body").on("julia.progress-change","#julia-player-"+e.env.ID,function(n,t){seekTo=e.Timecode.toSeconds(n.percent),seekTo=seekTo>=e.env.duration?e.env.duration:seekTo.toFixed(2),e.Controls.press("goto",{currentTime:seekTo})}),$("body").on("julia.volume-change","#julia-player-"+e.env.ID,function(n,t){e.Controls.press("volume",{volume:n.percent})}),$(window).on("resize",function(){e.Support.resize()})},n.native=function(){e.Support.forceReady()===!0&&e.env.isHls===!0?e.Api.canplaythrough():e.env.api.oncanplaythrough=function(n){e.env.duration=e.env.api.duration,e.env.started===!1&&e.env.api.readyState>=3&&e.Api.allowStart(n)},e.env.api.onplay=function(n){e.Ui.state(e.env.model.buttons.play,"play","pause"),e.Ui.icon(e.env.model.buttons.play,"julia-play","julia-pause"),e.env.model.buttons.bigPlay.hide(),e.Ui.posterUnset(),e.env.model.toolbar.show()},e.env.api.onplaying=function(n){e.Ui.state(e.env.model.buttons.play,"play","pause"),e.Ui.icon(e.env.model.buttons.play,"julia-play","julia-pause"),e.env.model.buttons.bigPlay.hide(),e.env.model.suggest.html(""),e.Ui.state(e.env.model.suggest,"on",""),e.env.model.toolbar.show(),e.Controls.press("setDuration",{duration:e.Timecode.toHuman(e.env.duration)}),e.env.started=!0},e.env.api.onpause=function(n){e.Ui.state(e.env.model.buttons.play,"pause","play"),e.Ui.icon(e.env.model.buttons.play,"julia-pause","julia-play"),setTimeout(function(){e.env.api.paused===!0&&e.env.model.buttons.bigPlay.show()},350)},e.env.api.onerror=function(e){},e.env.api.onemptied=function(e){},e.env.api.onstalled=function(e){},e.env.api.onsuspend=function(e){},e.env.api.ontimeupdate=function(n){currentTimeReadable=e.Timecode.toHuman(e.env.api.currentTime.toFixed(2)),e.env.seeking===!1&&(e.env.model.sliders.progress.update(e.Timecode.toPercents(e.env.api.currentTime)),e.Ui.panel(e.env.model.panels.currentTime,currentTimeReadable),e.Ui.state(e.env.model.preloader,"on","")),e.Callback.onTime(currentTimeReadable,e.env.api.currentTime),e.options.debugPlayback===!0&&e.Base.debug({"duration/current":e.env.duration+"/"+e.env.api.currentTime.toFixed(2)+" > "+currentTimeReadable})},e.env.api.onseeked=function(n){e.env.seeking=!1},e.env.api.onseeking=function(n){e.Ui.state(e.env.model.preloader,"","on"),e.env.seeking=!0},e.env.api.onvolumechange=function(n){e.env.api.muted===!1?e.env.model.sliders.volume.update(100*e.env.api.volume):e.env.model.sliders.volume.update(0)},e.env.api.ondurationchange=function(n){e.env.duration=e.env.api.duration,e.env.started===!1&&(e.env.duration=e.env.api.duration,e.env.seeking=!1,e.Base.debug({duration:e.env.duration,readyState:e.env.api.readyState,started:e.env.started}))},e.env.api.onended=function(n){e.Suggest.run()},$(window).on("blur",function(){e.options.pauseOnBlur===!0&&e.env.api.paused===!1&&e.env.started===!0&&e.Controls.press("pause")})},n.hlsLibEvents=function(){e.env.hls.on(Hls.Events.ERROR,function(n,t){switch(t.details){case Hls.ErrorDetails.MANIFEST_LOAD_ERROR:case Hls.ErrorDetails.MANIFEST_LOAD_TIMEOUT:case Hls.ErrorDetails.MANIFEST_PARSING_ERROR:case Hls.ErrorDetails.LEVEL_LOAD_ERROR:case Hls.ErrorDetails.LEVEL_LOAD_TIMEOUT:case Hls.ErrorDetails.LEVEL_SWITCH_ERROR:case Hls.ErrorDetails.FRAG_LOAD_ERROR:case Hls.ErrorDetails.FRAG_LOOP_LOADING_ERROR:case Hls.ErrorDetails.FRAG_LOAD_TIMEOUT:case Hls.ErrorDetails.FRAG_DECRYPT_ERROR:case Hls.ErrorDetails.FRAG_PARSING_ERROR:case Hls.ErrorDetails.BUFFER_APPEND_ERROR:case Hls.ErrorDetails.BUFFER_APPENDING_ERROR:e.Base.debug({recoveringError:t.details,errorType:t.type,errorFatal:t.fatal,data:t}),t.fatal===!0&&e.env.tries<11}})},n.dashLibEvents=function(){e.env.dash.on(dashjs.MediaPlayer.events,function(n,t){switch(t.details){case dashjs.MediaPlayer.events.ERROR:e.Base.debug({recoveringError:dashjs.MediaPlayer.events.ERROR})}})}},Julia.prototype._Controls=function(e){var n=this;n.press=function(n,t){switch(t=t||{},e.Base.debug({action:n,"action-data":t}),n){case"play":e.options.onPlay!==!1&&e.Callback.fn(e.options.onPlay,t),e.env.model.buttons.bigPlay.hide(),e.env.api.play();break;case"pause":e.options.onPause!==!1&&e.Callback.fn(e.options.onPause,t),e.env.api.pause();break;case"stop":e.options.onStop!==!1&&e.Callback.fn(e.options.onStop,t),e.env.api.pause(),e.env.api.currentTime=0,e.Ui.state(e.env.model.buttons.play,"pause","play"),e.Ui.icon(e.env.model.buttons.play,"julia-pause","julia-play"),e.env.model.buttons.bigPlay.show(),e.env.model.sliders.progress.update(0);break;case"goto":e.Ui.state(e.env.model.preloader,"","on"),e.env.api.currentTime=t.currentTime,e.options.onPosition!==!1&&e.Callback.fn(e.options.onPosition,t);break;case"setDuration":e.Ui.panel(e.env.model.panels.duration,t.duration),e.env.started===!1&&e.env.model.sliders.progress.update(0),e.Base.debug({setDuration:t.duration});break;case"volume":e.options.volume=t.volume,e.env.api.volume=t.volume/100,e.Base.debug({"volume is":e.env.api.volume}),e.env.model.sliders.volume.update(t.volume),t.volume>0?e.Controls.press("sound-on"):e.Controls.press("sound-off");break;case"sound-on":e.env.api.muted=!1,e.options.muted=!1,e.Persist.set("julia-player-volume",e.options.volume,999),e.Persist.set("julia-player-muted",e.options.muted,999),e.Ui.state(e.env.model.buttons.sound,"off","on"),e.Ui.icon(e.env.model.buttons.sound,"julia-sound-off","julia-sound-on");break;case"sound-off":e.env.api.muted=!0,e.options.muted=!0,e.Persist.set("julia-player-volume",e.options.volume,999),e.Persist.set("julia-player-muted",e.options.muted,999),e.Ui.state(e.env.model.buttons.sound,"on","off"),e.Ui.icon(e.env.model.buttons.sound,"julia-sound-on","julia-sound-off");break;case"fullscreen-on":e.Fullscreen.reset(e.env.instance,e.env.model,e.env.api),e.Fullscreen.on(e.env.fullscreenFrame);break;case"fullscreen-off":e.Fullscreen.reset(e.env.instance,e.env.model,e.env.api),e.Fullscreen.off()}}},Julia.prototype._Support=function(e){var n=this;n.aspect=function(e,n){return e>0&&n>0?n/e:0},n.isMobile=function(){return!!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile/i.test(navigator.userAgent)},n.iOS=function(){return!(!/iPad|iPhone|iPod/.test(navigator.userAgent)||window.MSStream)},n.forceReady=function(){return!!/Firefox/i.test(navigator.userAgent)},n.canPlayMedia=function(){var n=document.createElement("video");return n.id="video-cap-test-"+e.env.ID,e.env.canPlayMediaString=n.canPlayType("application/vnd.apple.mpegURL"),$("#video-cap-test"+e.env.ID).remove(),"probably"==e.env.canPlayMediaString||"maybe"==e.env.canPlayMediaString},n.resize=function(){defaultDim=e.env.element.width()?[e.env.element.width(),e.env.element.height()]:[e.options.width,e.options.height],dimensions=e.options.responsive===!0?n.getSize():defaultDim,e.Base.debug({resizeDefaults:defaultDim,resize:dimensions}),e.env.instance.width(dimensions[0]),e.env.instance.height(dimensions[1]),e.env.dimensions.width=dimensions[0],e.env.dimensions.height=dimensions[1],e.env.api.setAttribute("width","100%"),e.env.api.setAttribute("height","100%")},n.getSize=function(){var t=e.env.element.parent().css("display").toLowerCase();"inline"==t&&e.env.element.parent().css({display:"block"});var o=e.env.element.parent().width();for(i in e.options.dimensions){var s=e.options.dimensions[i];if(o>=s[0])return a=0==n.aspect(o)?s[1]/s[0]:n.aspect(e.env.api.videoWidth,e.env.api.videoHeight),dimensions=[s[0],s[0]*a],e.Base.debug({resizePredefined:dimensions}),dimensions}return a=0==n.aspect()?s[1]/s[0]:n.aspect(e.env.api.videoWidth,e.env.api.videoHeight),dimensions=[o,o*a],e.Base.debug({resizeFallback:dimensions}),dimensions}},Julia.prototype._Suggest=function(e){var n=this;n.run=function(){if(e.env.model.suggest.html(""),e.Controls.press("stop"),e.env.suggestClicked=!1,e.options.suggest.length>0){x=0;for(var n in e.options.suggest)if(x0?'':"",suggestItemWidget=$('
'+posterImage+'
'+e.options.suggest[n].title+"
"),suggestItemWidget.on("click",function(t){e.options.onSuggest!==!1&&e.Callback.fn(e.options.onSuggest,e.options.suggest[n]),e.options.muted=e.env.api.muted,e.options.poster=$(this).data("poster"),e.env.suggestClicked=!0,e.env.model.buttons.bigPlay.hide(),e.env.started=!1,e.options.source=$(this).data("source"),e.Api.source(),e.options.autoplay=!0,e.options.live="live"==$(this).data("mode"),e.options.i18n.liveText=$(this).data("live-text"),e.Ui.panel(e.env.model.panels.live,e.options.i18n.liveText),e.Base.debug({suggestRemoveIndex:$(this).data("index"),suggestRemove:$(this).data("source")}),e.options.suggest[$(this).data("index")].played=!0,e.Ui.state(e.env.model.suggest,"on",""),e.env.model.buttons.bigPlay.click()}),e.env.model.suggest.append(suggestItemWidget),x++}x>0&&(e.options.suggestTimeout>0&&e.Support.isMobile()===!1&&setTimeout(function(){e.env.suggestClicked===!1&&e.env.model.suggest.find("div.julia-suggest-item:first").click()},e.options.suggestTimeout),e.Ui.state(e.env.model.suggest,"","on"))}else e.Fullscreen.off();e.Base.debug({Suggest:"raised"})}},Julia.prototype._Fullscreen=function(e){var n=this;n.on=function(n){n.requestFullscreen?n.requestFullscreen():n.msRequestFullscreen?n.msRequestFullscreen():n.mozRequestFullScreen?n.mozRequestFullScreen():n.webkitRequestFullscreen?n.webkitRequestFullscreen():e.Base.debug({fullscreen:"Fullscreen is not supported"})},n.off=function(){document.exitFullscreen?document.exitFullscreen():document.msExitFullscreen?document.msExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()},n.reset=function(n,t,o){$(document).off("webkitfullscreenchange mozfullscreenchange fullscreenchange MSFullscreenChange"),$(document).on("webkitfullscreenchange mozfullscreenchange fullscreenchange MSFullscreenChange",function(i){document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement?(e.Ui.state(n,"julia-fullscreen-off","julia-fullscreen-on"),e.Ui.state(t.buttons.fullscreen,"on","off"),e.Ui.icon(t.buttons.fullscreen,"julia-fullscreen","julia-fullscreen-exit"),e.Support.isMobile()&&(screen.orientation.lock("landscape-primary"),screen.msLockOrientation.lock("landscape-primary"),screen.mozLockOrientation.lock("landscape-primary")),e.Base.debug({"fullscreen on":"#julia-player-"+e.env.ID})):(e.Ui.state(n,"julia-fullscreen-on","julia-fullscreen-off"),e.Ui.state(t.buttons.fullscreen,"off","on"),e.Ui.icon(t.buttons.fullscreen,"julia-fullscreen-exit","julia-fullscreen"),e.Support.isMobile()&&(screen.orientation.unlock(),screen.msLockOrientation.unlock(),screen.mozLockOrientation.unlock()),e.Base.debug({"fullscreen off":"#julia-player-"+e.env.ID})),e.Support.resize(),setTimeout(function(){w=e.env.api.getAttribute("width"),e.env.instance.find(".julia-progress").width(w),e.env.instance.find(".julia-progress .julia-slider-track").width(w),t.sliders.progress.update(e.Timecode.toPercents(o.currentTime))},5)})}},Julia.prototype._Persist=function(e){var n=this;n.set=function(e,n,t){dateObj=new Date,dateObj.setTime(dateObj.getTime()+24*t*60*60*1e3);var o="expires="+dateObj.toUTCString();document.cookie=e+"="+n+"; "+o+"; path=/"},n.get=function(e){for(var e=e+"=",n=document.cookie.split(";"),t=0;t1?parseInt(e[1]):0,h=e.length>2?parseInt(e[3]):0,t=s+60*m+60*h*60,t},n.toHuman=function(e){return e=e.toString().split("."),s=e[0],H=Math.floor(s/3600),M=Math.floor((s-3600*H)/60),S=Math.floor(s-3600*H-60*M),H=("0"+H.toString()).slice(-2),M=("0"+M.toString()).slice(-2),S=("0"+S.toString()).slice(-2),str=H>0?H+":"+M+":"+S:M+":"+S,str}},Julia.prototype._Callback=function(e){var n=this;n.fn=function(n,t){t=t||{},$.inArray(typeof n,["string","function","object"])>-1?("string"==typeof n&&(n=window[n]),n(e.options,e.env,t),e.Base.debug({Callback:typeof n+" raised"})):e.Base.debug({Callback:typeof n+" is not a function, but: "+typeof n})},n.onTime=function(n,t){n in e.options.onTime&&e.env.onTimeRised.indexOf(n)==-1&&(f=e.options.onTime[n],e.env.onTimeRised.push(n),$.inArray(typeof f,["string","function","object"])>-1?("string"==typeof f&&(f=window[f]),f(e.options,e.env,n),e.Base.debug({"Callback onTime":n+" "+typeof f+" raised"})):e.Base.debug({"Callback onTime":n+" "+typeof f+" is not a function, but: "+typeof f}))}},Julia.prototype._Inject=function(e){var n=this;n.source=function(n){$("#julia-player-"+e.env.ID).remove(),e.env.started=!1,$.extend(!0,e.options,n),e.Boot.run(),e.options.live===!0?(e.env.isLive=!0,e.Ui.panel(e.env.model.panels.live,e.options.i18n.liveText),e.Ui.state(e.env.model.toolbar,"","live")):(e.env.isLive=!1,e.Ui.panel(e.env.model.panels.live,""),e.Ui.state(e.env.model.toolbar,"live","")),e.Ui.state(e.env.model.preloader,"on",""),e.options.autoplay===!0&&e.Support.isMobile()===!1?e.env.model.buttons.bigPlay.click():e.env.model.buttons.bigPlay.show()}},Julia.prototype._Require=function(e){var n=this;n.js=function(e){if("string"==typeof e&&(e=[e]),0==e.length)n.raiseEvent("julia.no-plugins");else{var t=e[e.length-1];n.load(e,0,t)}},n.raiseEvent=function(t){setTimeout(function(){1==$("#julia-player-"+e.env.ID).length?$("#julia-player-"+e.env.ID).trigger({type:t}):n.raiseEvent(t)},20)},n.load=function(t,o,i){var s=t[o];e.Base.debug({"Require-js request":s}),$.getScript(s).done(function(){e.Base.debug({"Require-js loaded":s}),i==s?n.raiseEvent("julia.plugins-loaded"):n.load(t,o+1,i)})},n.css=function(e){"string"==typeof e&&(e=[e]);for(i in e)$("head").append($(''))}},Julia.prototype._Boot=function(e){var n=this;n.run=function(){e.Base.debug(e.options),e.env.element=e.options.element;for(i in e.options.suggest)e.options.suggest[i].played=!1;e.env.hls!==!1&&(e.env.hls.destroy(),e.env.hls=!1),e.env.dash!==!1&&(e.env.dash.reset(),e.env.dash=!1),e.Ui.create(),e.Api.source(),e.Api.create()}},Julia.prototype._Loader=function(e){var n=this;n.init=function(){e.env.api.src="",e.env.useHlsLib=!1,e.env.isLive=!1,e.env.canPlayMedia=e.Support.canPlayMedia(),e.env.isHls===!0&&(e.env.useHlsLib=!(e.env.canPlayMedia!==!1||!Hls.isSupported())),e.env.useHlsLib===!0?e.env.hls=new Hls(e.options.hlsConfig):e.env.isDash===!0||(e.env.api.src=e.env.source),e.options.live===!0?(e.env.isLive=!0,e.Ui.state(e.env.model.toolbar,"","live")):(e.env.isLive=!1,e.Ui.state(e.env.model.toolbar,"live","")),e.env.useHlsLib===!0?(e.Events.hlsLibEvents(),e.env.hls.autoLevelCapping=-1,e.env.hls.attachMedia(e.env.api),e.env.hls.loadSource(e.env.source),e.env.hls.on(Hls.Events.MEDIA_ATTACHED,function(n,t){e.env.hls.on(Hls.Events.LEVEL_LOADED,function(e,n){});for(x in e.options.triggerHls)handle=e.options.triggerHls[x],"function"==typeof window[handle]?e.env.hls.on(Hls.Events[x],function(n,t){window[handle](e.env.apiId,n,t)}):e.Base.debug({triggerHlsError:handle+" is not a function"})})):e.env.isDash===!0?(e.env.dash=dashjs.MediaPlayer().create(),e.env.dash.initialize(),e.env.dash.attachView(e.env.api),e.env.dash.attachSource(e.env.source),e.env.dash.setAutoPlay(e.options.autoplay),e.options.debug===!1&&e.env.dash.getDebug().setLogToBrowserConsole(!1),e.Events.dashLibEvents()):e.env.api.load(),e.Ui.state(e.env.model.preloader,"","on"),e.Api.allowStart({type:"origin.Loader"})}},jQuery.fn.julia=function(e){return this.play=function(){$(this).data("julia").Controls.press("play")},this.setOptions=function(e){$.extend(!0,$(this).data("julia").options,e)},this.options=function(){return $(this).data("julia").options},this.source=function(e){$(this).data("julia").Inject.source(e)},this.api=function(){return $(this).data("julia").api},this.pause=function(){$(this).data("julia").Controls.press("pause")},this.stop=function(){$(this).data("julia").Controls.press("stop")},this.goto=function(e){$(this).data("julia").Controls.press("goto",{currentTime:e})},this.mute=function(){$(this).data("julia").api.muted===!1?$(this).data("julia").Controls.press("sound-off"):$(this).data("julia").Controls.press("sound-on")},this.volume=function(e){$(this).data("julia").Controls.press("volume",{volume:e})},this.getID=function(){return $(this).data("julia").ID},this.stats=function(){return $(this).data("julia").stats()},this.each(function(){if(!$(this).data("julia")){e="undefined"==typeof e?{}:e,e.element=$(this);var n=new Julia(e);$(this).data("julia",n)}})}; \ No newline at end of file diff --git a/src/js/julia-events.js b/src/js/julia-events.js index 1cdbed3..a8d2d7a 100644 --- a/src/js/julia-events.js +++ b/src/js/julia-events.js @@ -271,10 +271,10 @@ Julia.prototype._Events = function(origin) // Video position origin.env.api.ontimeupdate = function(e) { + currentTimeReadable = origin.Timecode.toHuman( origin.env.api.currentTime.toFixed(2) ); + if(origin.env.seeking === false) { - currentTimeReadable = origin.Timecode.toHuman( origin.env.api.currentTime.toFixed(2) ); - origin.env.model.sliders.progress.update( origin.Timecode.toPercents( origin.env.api.currentTime ) ); origin.Ui.panel( diff --git a/src/js/julia-ui.js b/src/js/julia-ui.js index c41b542..1a07647 100644 --- a/src/js/julia-ui.js +++ b/src/js/julia-ui.js @@ -118,7 +118,6 @@ Julia.prototype._Ui = function(origin) origin.env.model.toolbar.hide(); origin.env.model.buttons.bigPlay.hide(); origin.Ui.state(origin.env.model.preloader, '', 'on'); - origin.env.instance.insertAfter(origin.env.element); origin.env.fullscreenFrame = document.querySelector('#julia-player-'+origin.env.ID);