define(['browser'], function (browser) { 'use strict'; var supportsTextTracks; var hlsPlayer; var requiresSettingStartTimeOnStart; var subtitleTrackIndexToSetOnPlaying; var currentTrackList; var currentPlayOptions; function htmlMediaRenderer(options) { var mediaElement; var self = this; function onEnded() { destroyCustomTrack(this); Events.trigger(self, '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; // } // } //} if (options.type == 'video') { // Get the player position + the transcoding offset var timeMs = this.currentTime * 1000; timeMs += ((currentPlayOptions.startTimeTicksOffset || 0) / 10000); updateSubtitleText(timeMs); } Events.trigger(self, 'timeupdate'); } function onVolumeChange() { Events.trigger(self, 'volumechange'); } function onOneAudioPlaying(e) { var elem = e.target; elem.removeEventListener('playing', onOneAudioPlaying); document.querySelector('.mediaPlayerAudioContainer').classList.add('hide'); } function onPlaying() { Events.trigger(self, 'playing'); } function onPlay() { Events.trigger(self, 'play'); } function onPause() { Events.trigger(self, 'pause'); } function onClick() { Events.trigger(self, 'click'); } function onDblClick() { Events.trigger(self, 'dblclick'); } function onError(e) { destroyCustomTrack(this); var elem = e.target; var errorCode = elem.error ? elem.error.code : ''; console.log('Media element error code: ' + errorCode); Events.trigger(self, 'error'); } function onLoadedMetadata(e) { var elem = e.target; elem.removeEventListener('loadedmetadata', onLoadedMetadata); if (!hlsPlayer) { elem.play(); } } function requireHlsPlayer(callback) { require(['hlsjs'], function (hls) { window.Hls = hls; callback(); }); } function onOneVideoPlaying(e) { var element = e.target; element.removeEventListener('playing', onOneVideoPlaying); self.setCurrentTrackElement(subtitleTrackIndexToSetOnPlaying); var requiresNativeControls = !self.enableCustomVideoControls(); if (requiresNativeControls) { element.setAttribute('controls', 'controls'); } if (requiresSettingStartTimeOnStart) { var startPositionInSeekParam = currentPlayOptions.startPositionInSeekParam; // Appending #t=xxx to the query string doesn't seem to work with HLS if (startPositionInSeekParam && currentSrc.indexOf('.m3u8') != -1) { var delay = browser.safari ? 2500 : 0; if (delay) { setTimeout(function () { element.currentTime = startPositionInSeekParam; }, delay); } else { element.currentTime = startPositionInSeekParam; } } } } function createAudioElement() { var elem = document.querySelector('.mediaPlayerAudio'); if (!elem) { var html = ''; var requiresControls = !MediaPlayer.canAutoPlayAudio(); if (requiresControls) { html += '