From 1dee5f70b0b1a359f23720bbe7a442c8f8b33b10 Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Thu, 17 Aug 2017 15:33:02 -0400 Subject: [PATCH] feat: add an option to force cardboard button (#20) --- index.html | 2 +- src/plugin.js | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index ce8d3c39..afaa26ae 100644 --- a/index.html +++ b/index.html @@ -22,7 +22,7 @@ player.mediainfo.projection = '360'; // AUTO is the default and looks at mediainfo - player.vr({projection: 'AUTO', debug: true}); + player.vr({projection: 'AUTO', debug: true, forceCardboard: false}); }(window, window.videojs)); diff --git a/src/plugin.js b/src/plugin.js index aa2cd840..d53552d6 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -35,6 +35,7 @@ const validProjections = [ // Default options for the plugin. const defaults = { projection: 'AUTO', + forceCardboard: false, debug: false }; @@ -450,8 +451,11 @@ class VR extends Plugin { this.player_.removeChild('BigPlayButton'); this.player_.addChild('BigVrPlayButton', {}, this.bigPlayButtonIndex_); this.player_.bigPlayButton = this.player_.getChild('BigVrPlayButton'); - // mobile devices - if (videojs.browser.IS_ANDROID || videojs.browser.IS_IOS) { + + // mobile devices, or cardboard forced to on + if (this.options_.forceCardboard || + videojs.browser.IS_ANDROID || + videojs.browser.IS_IOS) { this.player_.controlBar.addChild('CardboardButton', {}); } @@ -570,7 +574,7 @@ class VR extends Plugin { } // remove the cardboard button - if (videojs.browser.IS_ANDROID || videojs.browser.IS_IOS) { + if (this.player_.getChild('CardboardButton')) { this.player_.controlBar.removeChild('CardboardButton'); }