Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add a cardboard button for native webvr support #22

Merged
merged 2 commits into from
Aug 17, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: add a cardboard button for native webvr support
  • Loading branch information
gkatsev committed Aug 17, 2017
commit 88b429a6d288eed51779707afd813d19cf78ee9c
12 changes: 11 additions & 1 deletion src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ class VR extends Plugin {
if (this.options_.forceCardboard ||
videojs.browser.IS_ANDROID ||
videojs.browser.IS_IOS) {
this.player_.controlBar.addChild('CardboardButton', {});
this.addCardboardButton_();
}

// if ios remove full screen toggle
Expand Down Expand Up @@ -523,6 +523,10 @@ class VR extends Plugin {
this.log('WebVR supported, VRDisplays found.');
this.vrDisplay = displays[0];
this.log(this.vrDisplay);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be good to add a comment here about checking for native vr displays

if (!this.vrDisplay.isPolyfilled) {
this.addCardboardButton_();
}
} else {
this.triggerError_({code: 'web-vr-no-devices-found', dismiss: false});
}
Expand All @@ -543,6 +547,12 @@ class VR extends Plugin {
this.initialized_ = true;
}

addCardboardButton_() {
if (!this.player_.getChild('CardboardButton')) {
this.player_.controlBar.addChild('CardboardButton', {});
}
}

getVideoEl_() {
return this.player_.el().getElementsByTagName('video')[0];
}
Expand Down