aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/media.js
diff options
context:
space:
mode:
authorSam Potts <sam@potts.es>2020-04-24 00:32:16 +1000
committerSam Potts <sam@potts.es>2020-04-24 00:32:16 +1000
commit3b521f73bd773dcb530746db47c90dbb1349b70b (patch)
tree371bb120c654d55d0016792b9412fc122735c1b8 /src/js/media.js
parent27126b20bc5d2a3a8947c363d1f1887533f69688 (diff)
parent68137aa789b195b26d4306eaebc7fee2f8eb3374 (diff)
downloadplyr-3b521f73bd773dcb530746db47c90dbb1349b70b.tar.lz
plyr-3b521f73bd773dcb530746db47c90dbb1349b70b.tar.xz
plyr-3b521f73bd773dcb530746db47c90dbb1349b70b.zip
Merge branch 'develop' of github.com:sampotts/plyr into develop
# Conflicts: # package.json # yarn.lock
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;