(function () { var supportsTextTracks; var isViblastStarted; 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 (!isViblastStarted) { this.play(); } } function requireViblast(callback) { require(['thirdparty/viblast/viblast.js'], function () { if (htmlMediaRenderer.customViblastKey) { callback(); } else { downloadViblastKey(callback); } }); } function downloadViblastKey(callback) { var savedKeyPropertyName = 'vbk'; var savedKey = appStorage.getItem(savedKeyPropertyName); if (savedKey) { htmlMediaRenderer.customViblastKey = savedKey; callback(); return; } var headers = {}; headers['X-Emby-Token'] = 'EMBY_SERVER'; HttpClient.send({ type: 'GET', url: 'https://mb3admin.com/admin/service/registration/getViBlastKey', headers: headers }).done(function (key) { appStorage.setItem(savedKeyPropertyName, key); htmlMediaRenderer.customViblastKey = key; callback(); }).fail(function () { callback(); }); } function getViblastKey() { return htmlMediaRenderer.customViblastKey || 'N8FjNTQ3NDdhZqZhNGI5NWU5ZTI='; } 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 element = this; setTimeout(function () { element.currentTime = startPositionInSeekParam; }, 2500); } } } function createAudioElement() { var elem = $('.mediaPlayerAudio'); if (!elem.length) { var html = ''; var requiresControls = !MediaPlayer.canAutoPlayAudio(); if (requiresControls) { html += '
';; } else { html += ''; $(document.body).append(html); elem = $('.mediaPlayerAudio'); } return $(elem) .on('timeupdate', onTimeUpdate) .on('ended', onEnded) .on('volumechange', onVolumeChange) .one('playing', onOneAudioPlaying) .on('play', onPlay) .on('pause', onPause) .on('playing', onPlaying) .on('error', onError)[0]; } function enableViblast(src) { if (src) { if (src.indexOf('.m3u8') == -1) { return false; } } return MediaPlayer.canPlayHls() && !MediaPlayer.canPlayNativeHls(); } function createVideoElement() { var html = ''; var requiresNativeControls = !self.enableCustomVideoControls(); // Safari often displays the poster under the video and it doesn't look good var poster = !$.browser.safari && options.poster ? (' poster="' + options.poster + '"') : ''; // Can't autoplay in these browsers so we need to use the full controls if (requiresNativeControls && AppInfo.isNativeApp && $.browser.android) { html += '