function change(input) {
        var _this2 = this;

        if (!utils.is.object(input) || !('sources' in input) || !input.sources.length) {
            this.debug.warn('Invalid source format');
            return;
        }

        // Cancel current network requests
        media.cancelRequests.call(this);

        // Destroy instance and re-setup
        this.destroy.call(this, function () {
            // TODO: Reset menus here

            // Remove elements
            utils.removeElement(_this2.media);
            _this2.media = null;

            // Reset class name
            if (utils.is.element(_this2.elements.container)) {
                _this2.elements.container.removeAttribute('class');
            }

            // Set the type and provider
            _this2.type = input.type;
            _this2.provider = !utils.is.empty(input.sources[0].provider) ? input.sources[0].provider : providers.html5;

            // Check for support
            _this2.supported = support.check(_this2.type, _this2.provider, _this2.config.inline);

            // Create new markup
            switch (_this2.provider + ':' + _this2.type) {
                case 'html5:video':
                    _this2.media = utils.createElement('video');
                    break;

                case 'html5:audio':
                    _this2.media = utils.createElement('audio');
                    break;

                case 'youtube:video':
                case 'vimeo:video':
                    _this2.media = utils.createElement('div', {
                        src: input.sources[0].src
                    });
                    break;

                default:
                    break;
            }

            // Inject the new element
            _this2.elements.container.appendChild(_this2.media);

            // Autoplay the new source?
            if (utils.is.boolean(input.autoplay)) {
                _this2.config.autoplay = input.autoplay;
            }

            // Set attributes for audio and video
            if (_this2.isHTML5) {
                if (_this2.config.crossorigin) {
                    _this2.media.setAttribute('crossorigin', '');
                }
                if (_this2.config.autoplay) {
                    _this2.media.setAttribute('autoplay', '');
                }
                if ('poster' in input) {
                    _this2.media.setAttribute('poster', input.poster);
                }
                if (_this2.config.loop.active) {
                    _this2.media.setAttribute('loop', '');
                }
                if (_this2.config.muted) {
                    _this2.media.setAttribute('muted', '');
                }
                if (_this2.config.inline) {
                    _this2.media.setAttribute('playsinline', '');
                }
            }

            // Restore class hook
            ui.addStyleHook.call(_this2);

            // Set new sources for html5
            if (_this2.isHTML5) {
                source.insertElements.call(_this2, 'source', input.sources);
            }

            // Set video title
            _this2.config.title = input.title;

            // Set up from scratch
            media.setup.call(_this2);

            // HTML5 stuff
            if (_this2.isHTML5) {
                // Setup captions
                if ('tracks' in input) {
                    source.insertElements.call(_this2, 'track', input.tracks);
                }

                // Load HTML5 sources
                _this2.media.load();
            }

            // If HTML5 or embed but not fully supported, setupInterface and call ready now
            if (_this2.isHTML5 || _this2.isEmbed && !_this2.supported.ui) {
                // Setup interface
                ui.build.call(_this2);
            }

            // Update the fullscreen support
            _this2.fullscreen.update();
        }, true);
    }
// Sources are not checked for support so be careful
Sources are not checked for support so be careful
Sources are not checked for support so be careful
function change(input) {
        var _this2 = this;
        if (!utils.is.object(input) || !('sources' in input) || !input.sources.length) {
            this.debug.warn('Invalid source format');
            return;
        }
        media.cancelRequests.call(this);
        this.destroy.call(this, function () {
            utils.removeElement(_this2.media);
            _this2.media = null;
            if (utils.is.element(_this2.elements.container)) {
                _this2.elements.container.removeAttribute('class');
            }
            _this2.type = input.type;
            _this2.provider = !utils.is.empty(input.sources[0].provider) ? input.sources[0].provider : providers.html5;
            _this2.supported = support.check(_this2.type, _this2.provider, _this2.config.inline);
            switch (_this2.provider + ':' + _this2.type) {
                case 'html5:video':
                    _this2.media = utils.createElement('video');
                    break;
                case 'html5:audio':
                    _this2.media = utils.createElement('audio');
                    break;
                case 'youtube:video':
                case 'vimeo:video':
                    _this2.media = utils.createElement('div', {
                        src: input.sources[0].src
                    });
                    break;
                default:
                    break;
            }
            _this2.elements.container.appendChild(_this2.media);
            if (utils.is.boolean(input.autoplay)) {
                _this2.config.autoplay = input.autoplay;
            }
            if (_this2.isHTML5) {
                if (_this2.config.crossorigin) {
                    _this2.media.setAttribute('crossorigin', '');
                }
                if (_this2.config.autoplay) {
                    _this2.media.setAttribute('autoplay', '');
                }
                if ('poster' in input) {
                    _this2.media.setAttribute('poster', input.poster);
                }
                if (_this2.config.loop.active) {
                    _this2.media.setAttribute('loop', '');
                }
                if (_this2.config.muted) {
                    _this2.media.setAttribute('muted', '');
                }
                if (_this2.config.inline) {
                    _this2.media.setAttribute('playsinline', '');
                }
            }
            ui.addStyleHook.call(_this2);
            if (_this2.isHTML5) {
                source.insertElements.call(_this2, 'source', input.sources);
            }
            _this2.config.title = input.title;
            media.setup.call(_this2);
            if (_this2.isHTML5) {
                if ('tracks' in input) {
                    source.insertElements.call(_this2, 'track', input.tracks);
                }
                _this2.media.load();
            }
            if (_this2.isHTML5 || _this2.isEmbed && !_this2.supported.ui) {
                ui.build.call(_this2);
            }
            _this2.fullscreen.update();
        }, true);
    }
function change ( input ) { var _this2 = this ; if ( ! utils . is . object ( input ) || ! ( 'sources' in input ) || ! input . sources . length ) { this . debug . warn ( 'Invalid source format' ) ; return ; } media . cancelRequests . call ( this ) ; this . destroy . call ( this , function ( ) { utils . removeElement ( _this2 . media ) ; _this2 . media = null ; if ( utils . is . element ( _this2 . elements . container ) ) { _this2 . elements . container . removeAttribute ( 'class' ) ; } _this2 . type = input . type ; _this2 . provider = ! utils . is . empty ( input . sources [ 0 ] . provider ) ? input . sources [ 0 ] . provider : providers . html5 ; _this2 . supported = support . check ( _this2 . type , _this2 . provider , _this2 . config . inline ) ; switch ( _this2 . provider + ':' + _this2 . type ) { case 'html5:video' : _this2 . media = utils . createElement ( 'video' ) ; break ; case 'html5:audio' : _this2 . media = utils . createElement ( 'audio' ) ; break ; case 'youtube:video' : case 'vimeo:video' : _this2 . media = utils . createElement ( 'div' , { src : input . sources [ 0 ] . src } ) ; break ; default : break ; } _this2 . elements . container . appendChild ( _this2 . media ) ; if ( utils . is . boolean ( input . autoplay ) ) { _this2 . config . autoplay = input . autoplay ; } if ( _this2 . isHTML5 ) { if ( _this2 . config . crossorigin ) { _this2 . media . setAttribute ( 'crossorigin' , '' ) ; } if ( _this2 . config . autoplay ) { _this2 . media . setAttribute ( 'autoplay' , '' ) ; } if ( 'poster' in input ) { _this2 . media . setAttribute ( 'poster' , input . poster ) ; } if ( _this2 . config . loop . active ) { _this2 . media . setAttribute ( 'loop' , '' ) ; } if ( _this2 . config . muted ) { _this2 . media . setAttribute ( 'muted' , '' ) ; } if ( _this2 . config . inline ) { _this2 . media . setAttribute ( 'playsinline' , '' ) ; } } ui . addStyleHook . call ( _this2 ) ; if ( _this2 . isHTML5 ) { source . insertElements . call ( _this2 , 'source' , input . sources ) ; } _this2 . config . title = input . title ; media . setup . call ( _this2 ) ; if ( _this2 . isHTML5 ) { if ( 'tracks' in input ) { source . insertElements . call ( _this2 , 'track' , input . tracks ) ; } _this2 . media . load ( ) ; } if ( _this2 . isHTML5 || _this2 . isEmbed && ! _this2 . supported . ui ) { ui . build . call ( _this2 ) ; } _this2 . fullscreen . update ( ) ; } , true ) ; }
Sources are not checked for support so be careful
Sources are not checked for support so be careful
// Cancel current network requests // Destroy instance and re-setup // TODO: Reset menus here // Remove elements // Reset class name // Set the type and provider // Check for support // Create new markup // Inject the new element // Autoplay the new source? // Set attributes for audio and video // Restore class hook // Set new sources for html5 // Set video title // Set up from scratch // HTML5 stuff // Setup captions // Load HTML5 sources // If HTML5 or embed but not fully supported, setupInterface and call ready now // Setup interface // Update the fullscreen support