(function (document, clearTimeout, screen, localStorage, _V_, $, setInterval, window) { function mediaPlayer() { var self = this; var testableAudioElement = document.createElement('audio'); var testableVideoElement = document.createElement('video'); var currentMediaElement; var currentProgressInterval; if (typeof(self.playing) == 'undefined') { self.playing = ''; } if (typeof(self.queue) == 'undefined') { self.queue = []; } function endsWith(text, pattern) { text = text.toLowerCase(); pattern = pattern.toLowerCase(); var d = text.length - pattern.length; return d >= 0 && text.lastIndexOf(pattern) === d; } function playAudio(item, params) { var volume = localStorage.getItem("volume") || 0.5; var baseParams = { audioChannels: 2, audioBitrate: 128000 }; $.extend(baseParams, params); var mp3Url = ApiClient.getUrl('Audio/' + item.Id + '/stream.mp3', $.extend({}, baseParams, { audioCodec: 'mp3' })); var aacUrl = ApiClient.getUrl('Audio/' + item.Id + '/stream.aac', $.extend({}, baseParams, { audioCodec: 'aac' })); var webmUrl = ApiClient.getUrl('Audio/' + item.Id + '/stream.webm', $.extend({}, baseParams, { audioCodec: 'Vorbis' })); var mediaStreams = item.MediaStreams || []; for (var i = 0, length = mediaStreams.length; i < length; i++) { var stream = mediaStreams[i]; if (stream.Type == "Audio") { // Stream statically when possible if (endsWith(item.Path, ".aac") && stream.BitRate <= 256000) { aacUrl += "&static=true"; } else if (endsWith(item.Path, ".mp3") && stream.BitRate <= 256000) { mp3Url += "&static=true"; } break; } } /* ffmpeg always says the ogg stream is corrupt after conversion var oggUrl = ApiClient.getUrl('Audio/' + item.Id + '/stream.oga', $.extend({}, baseParams, { audioCodec: 'Vorbis' })); */ var html = ''; html += '