diff options
author | Sam Potts <me@sampotts.me> | 2017-11-23 17:35:35 +1100 |
---|---|---|
committer | Sam Potts <me@sampotts.me> | 2017-11-23 17:35:35 +1100 |
commit | 921cefd212f65290349aa1d9d533c95cb1f6fcce (patch) | |
tree | 69c58f43d154440d9f327fb5028372a488522fe2 /src/js/source.js | |
parent | de6f0f1b778180f7b26f85f45053ffb97eb526af (diff) | |
download | plyr-921cefd212f65290349aa1d9d533c95cb1f6fcce.tar.lz plyr-921cefd212f65290349aa1d9d533c95cb1f6fcce.tar.xz plyr-921cefd212f65290349aa1d9d533c95cb1f6fcce.zip |
Moved to provider + type to make it cleaner in future, fix for multiple players
Diffstat (limited to 'src/js/source.js')
-rw-r--r-- | src/js/source.js | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/src/js/source.js b/src/js/source.js index c670ab09..cbea5433 100644 --- a/src/js/source.js +++ b/src/js/source.js @@ -2,7 +2,7 @@ // Plyr source update // ========================================================================== -import types from './types'; +import { providers } from './types'; import utils from './utils'; import media from './media'; import ui from './ui'; @@ -48,35 +48,25 @@ const source = { this.elements.container.removeAttribute('class'); } - // Set the type - if ('type' in input) { - this.type = input.type; - - // Get child type for video (it might be an embed) - if (this.type === 'video') { - const firstSource = input.sources[0]; - - if ('type' in firstSource && types.embed.includes(firstSource.type)) { - this.type = firstSource.type; - } - } - } + // Set the type and provider + this.type = input.type; + this.provider = !utils.is.empty(input.sources[0].provider) ? input.sources[0].provider : providers.html5; // Check for support - this.supported = support.check(this.type, this.config.inline); + this.supported = support.check(this.type, this.provider, this.config.inline); // Create new markup - switch (this.type) { - case 'video': + switch (`${this.provider}:${this.type}`) { + case 'html5:video': this.media = utils.createElement('video'); break; - case 'audio': + case 'html5:audio': this.media = utils.createElement('audio'); break; - case 'youtube': - case 'vimeo': + case 'youtube:video': + case 'vimeo:video': this.media = utils.createElement('div'); this.embedId = input.sources[0].src; break; @@ -117,7 +107,6 @@ const source = { // Restore class hooks utils.toggleClass(this.elements.container, this.config.classNames.captions.active, this.supported.ui && this.captions.enabled); - ui.addStyleHook.call(this); // Set new sources for html5 |