From 84de6a0f50e895c37cb3a263fd1e32e03501aefc Mon Sep 17 00:00:00 2001 From: Tsachi Shlidor Date: Wed, 22 Apr 2020 11:27:43 +0300 Subject: [PATCH] Interactive plugin clean up --- src/components/shoppable-bar/shoppable-widget.js | 5 ++++- src/plugins/cld-interactive-video/index.js | 11 ----------- src/plugins/index.js | 4 ++-- src/plugins/interactive-plugin/index.js | 10 ++++++++++ src/video-player.js | 6 ++++-- 5 files changed, 20 insertions(+), 16 deletions(-) delete mode 100644 src/plugins/cld-interactive-video/index.js create mode 100644 src/plugins/interactive-plugin/index.js diff --git a/src/components/shoppable-bar/shoppable-widget.js b/src/components/shoppable-bar/shoppable-widget.js index 75bc1a93..81834195 100644 --- a/src/components/shoppable-bar/shoppable-widget.js +++ b/src/components/shoppable-bar/shoppable-widget.js @@ -23,7 +23,10 @@ class ShoppableWidget { constructor(player, options = {}) { this.options_ = videojs.mergeOptions(OPTIONS_DEFAULTS, options); this.player_ = player; - this.render(); + + this.init = () => { + this.render(); + }; if (this.options_.showPostPlayOverlay) { this.player_.on('ended', () => { diff --git a/src/plugins/cld-interactive-video/index.js b/src/plugins/cld-interactive-video/index.js deleted file mode 100644 index 0a23e8dc..00000000 --- a/src/plugins/cld-interactive-video/index.js +++ /dev/null @@ -1,11 +0,0 @@ -import ShoppableWidget from '../../components/shoppable-bar/shoppable-widget'; - -export default function cldInteractivePlugin(player, options) { - if (options) { - // eslint-disable-next-line no-new - new ShoppableWidget(player, options); - } - -} - - diff --git a/src/plugins/index.js b/src/plugins/index.js index fca99a03..47f19450 100644 --- a/src/plugins/index.js +++ b/src/plugins/index.js @@ -3,7 +3,7 @@ import 'videojs-contrib-ads'; import './ima'; import 'dashjs'; import 'videojs-contrib-dash'; -import shoppable from './cld-interactive-video'; +import interactive from './interactive-plugin'; // #endif import 'videojs-per-source-behaviors'; import autoplayOnScroll from './autoplay-on-scroll'; @@ -21,6 +21,6 @@ export { cloudinary, analytics, // #if (!process.env.WEBPACK_BUILD_LIGHT) - shoppable + interactive // #endif }; diff --git a/src/plugins/interactive-plugin/index.js b/src/plugins/interactive-plugin/index.js new file mode 100644 index 00000000..626039ac --- /dev/null +++ b/src/plugins/interactive-plugin/index.js @@ -0,0 +1,10 @@ +import ShoppableWidget from '../../components/shoppable-bar/shoppable-widget'; + +export default function interactivePlugin(player, options) { + + // Shoppable Video + if (options.shoppable) { + new ShoppableWidget(player, options.shoppable).init(); + } + +} diff --git a/src/video-player.js b/src/video-player.js index eb3e279c..2cde0307 100644 --- a/src/video-player.js +++ b/src/video-player.js @@ -522,8 +522,10 @@ class VideoPlayer extends Utils.mixin(Eventable) { if (publicId instanceof VideoSource) { return this.videojs.cloudinary.source(publicId, options); } - if (this.videojs.shoppable) { - this.videojs.shoppable(this.videojs, options.shoppable); + + // Interactive plugin - available in full (not light) build only + if (this.videojs.interactive) { + this.videojs.interactive(this.videojs, options); } if (VideoPlayer.allowUsageReport()) {