define(['pluginManager', 'events', 'browser', 'embyRouter'], function (pluginManager, Events, browser, embyRouter) { "use strict"; return function () { var self = this; self.name = 'Youtube Player'; self.type = 'mediaplayer'; self.id = 'youtubeplayer'; // Let any players created by plugins take priority self.priority = 1; var videoDialog; var currentSrc; var started = false; var currentYoutubePlayer; var timeUpdateInterval; self.canPlayMediaType = function (mediaType) { mediaType = (mediaType || '').toLowerCase(); return mediaType === 'audio' || mediaType === 'video'; }; self.canPlayItem = function (item) { // Does not play server items return false; }; self.canPlayUrl = function (url) { return url.toLowerCase().indexOf('youtube.com') !== -1; }; self.getDeviceProfile = function () { return Promise.resolve({}); }; self.currentSrc = function () { return currentSrc; }; self.play = function (options) { started = false; return createMediaElement(options).then(function (elem) { return setCurrentSrc(elem, options); }); }; function setCurrentSrc(elem, options) { return new Promise(function (resolve, reject) { require(['queryString'], function (queryString) { currentSrc = options.url; var params = queryString.parse(options.url.split('?')[1]); // 3. This function creates an