Skip to content

Commit

Permalink
feat: add an option to force cardboard button (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey authored Aug 17, 2017
1 parent 6f09814 commit 1dee5f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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));
</script>
</body>
Expand Down
10 changes: 7 additions & 3 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const validProjections = [
// Default options for the plugin.
const defaults = {
projection: 'AUTO',
forceCardboard: false,
debug: false
};

Expand Down Expand Up @@ -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', {});
}

Expand Down Expand Up @@ -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');
}

Expand Down

0 comments on commit 1dee5f7

Please sign in to comment.