(function () { var supportsTextTracks; var hlsPlayer; var requiresSettingStartTimeOnStart; function htmlMediaRenderer(options) { var mediaElement; var self = this; function hideStatusBar() { if (options.type == 'video' && window.StatusBar) { //StatusBar.backgroundColorByName("black"); //StatusBar.overlaysWebView(true); StatusBar.hide(); } } function showStatusBar() { if (options.type == 'video' && window.StatusBar) { StatusBar.show(); //StatusBar.overlaysWebView(false); } } function onEnded() { showStatusBar(); $(self).trigger('ended'); } function onTimeUpdate() { //if (isViblastStarted) { // // This is a workaround for viblast not stopping playback at the end // var time = this.currentTime; // var duration = this.duration; // if (duration) { // if (time >= (duration - 1)) { // //onEnded(); // return; // } // } //} $(self).trigger('timeupdate'); } function onVolumeChange() { $(self).trigger('volumechange'); } function onOneAudioPlaying() { $('.mediaPlayerAudioContainer').hide(); } function onPlaying() { $(self).trigger('playing'); } function onPlay() { $(self).trigger('play'); } function onPause() { $(self).trigger('pause'); } function onClick() { $(self).trigger('click'); } function onDblClick() { $(self).trigger('dblclick'); } function onError() { var errorCode = this.error ? this.error.code : ''; Logger.log('Media element error code: ' + errorCode); showStatusBar(); $(self).trigger('error'); } function onLoadedMetadata() { if (!hlsPlayer) { this.play(); } } function requireHlsPlayer(callback) { require(['thirdparty/hls.min.js'], function(hls) { window.Hls = hls; callback(); }); } function getStartTime(url) { var src = url; var parts = src.split('#'); if (parts.length > 1) { parts = parts[parts.length - 1].split('='); if (parts.length == 2) { return parseFloat(parts[1]); } } return 0; } function onOneVideoPlaying() { hideStatusBar(); var requiresNativeControls = !self.enableCustomVideoControls(); if (requiresNativeControls) { $(this).attr('controls', 'controls'); } if (requiresSettingStartTimeOnStart) { var src = (self.currentSrc() || '').toLowerCase(); var startPositionInSeekParam = getStartTime(src); // Appending #t=xxx to the query string doesn't seem to work with HLS if (startPositionInSeekParam && src.indexOf('.m3u8') != -1) { var delay = $.browser.safari ? 2500 : 0; var element = this; if (delay) { setTimeout(function () { element.currentTime = startPositionInSeekParam; }, delay); } else { element.currentTime = startPositionInSeekParam; } } } } function createAudioElement() { var elem = $('.mediaPlayerAudio'); if (!elem.length) { var html = ''; var requiresControls = !MediaPlayer.canAutoPlayAudio(); if (requiresControls) { html += '