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 all commits
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
15 changes: 14 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,13 @@ 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

// Native WebVR Head Mounted Displays (HMDs) like the HTC Vive
// also need the cardboard button to enter fully immersive mode
// so, we want to add the button if we're not polyfilled.
if (!this.vrDisplay.isPolyfilled) {
this.addCardboardButton_();
}
} else {
this.triggerError_({code: 'web-vr-no-devices-found', dismiss: false});
}
Expand All @@ -543,6 +550,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