aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/media.js
diff options
context:
space:
mode:
authorSam Potts <sam@potts.es>2020-04-28 22:20:49 +1000
committerGitHub <noreply@github.com>2020-04-28 22:20:49 +1000
commit99a26d65cf78851878841c5afc54830f1222ccb1 (patch)
tree6a2bf12ecfa2314725e6d8961ec9f6a986b5003b /src/js/media.js
parent6aa21c1fae4a7b6dbcf1db1ee3b06f11d674869a (diff)
parent4915cf0120870db4a52b3be117efa22f8ca2bd3e (diff)
downloadplyr-99a26d65cf78851878841c5afc54830f1222ccb1.tar.lz
plyr-99a26d65cf78851878841c5afc54830f1222ccb1.tar.xz
plyr-99a26d65cf78851878841c5afc54830f1222ccb1.zip
Merge pull request #1796 from sampotts/develop
v3.6.0
Diffstat (limited to 'src/js/media.js')
-rw-r--r--src/js/media.js94
1 files changed, 46 insertions, 48 deletions
diff --git a/src/js/media.js b/src/js/media.js
index 8c08456d..4584fea3 100644
--- a/src/js/media.js
+++ b/src/js/media.js
@@ -8,54 +8,52 @@ import youtube from './plugins/youtube';
import { createElement, toggleClass, wrap } from './utils/elements';
const media = {
- // Setup media
- setup() {
- // If there's no media, bail
- if (!this.media) {
- this.debug.warn('No media element found!');
- return;
- }
-
- // Add type class
- toggleClass(this.elements.container, this.config.classNames.type.replace('{0}', this.type), true);
-
- // Add provider class
- toggleClass(this.elements.container, this.config.classNames.provider.replace('{0}', this.provider), true);
-
- // Add video class for embeds
- // This will require changes if audio embeds are added
- if (this.isEmbed) {
- toggleClass(this.elements.container, this.config.classNames.type.replace('{0}', 'video'), true);
- }
-
- // Inject the player wrapper
- if (this.isVideo) {
- // Create the wrapper div
- this.elements.wrapper = createElement('div', {
- class: this.config.classNames.video,
- });
-
- // Wrap the video in a container
- wrap(this.media, this.elements.wrapper);
-
- // Faux poster container
- if (this.isEmbed) {
- this.elements.poster = createElement('div', {
- class: this.config.classNames.poster,
- });
-
- this.elements.wrapper.appendChild(this.elements.poster);
- }
- }
-
- if (this.isHTML5) {
- html5.setup.call(this);
- } else if (this.isYouTube) {
- youtube.setup.call(this);
- } else if (this.isVimeo) {
- vimeo.setup.call(this);
- }
- },
+ // Setup media
+ setup() {
+ // If there's no media, bail
+ if (!this.media) {
+ this.debug.warn('No media element found!');
+ return;
+ }
+
+ // Add type class
+ toggleClass(this.elements.container, this.config.classNames.type.replace('{0}', this.type), true);
+
+ // Add provider class
+ toggleClass(this.elements.container, this.config.classNames.provider.replace('{0}', this.provider), true);
+
+ // Add video class for embeds
+ // This will require changes if audio embeds are added
+ if (this.isEmbed) {
+ toggleClass(this.elements.container, this.config.classNames.type.replace('{0}', 'video'), true);
+ }
+
+ // Inject the player wrapper
+ if (this.isVideo) {
+ // Create the wrapper div
+ this.elements.wrapper = createElement('div', {
+ class: this.config.classNames.video,
+ });
+
+ // Wrap the video in a container
+ wrap(this.media, this.elements.wrapper);
+
+ // Poster image container
+ this.elements.poster = createElement('div', {
+ class: this.config.classNames.poster,
+ });
+
+ this.elements.wrapper.appendChild(this.elements.poster);
+ }
+
+ if (this.isHTML5) {
+ html5.setup.call(this);
+ } else if (this.isYouTube) {
+ youtube.setup.call(this);
+ } else if (this.isVimeo) {
+ vimeo.setup.call(this);
+ }
+ },
};
export default media;