Skip to content

Commit

Permalink
chore: Swap webvr ro webxr polyfill packages (add iOS permission chec…
Browse files Browse the repository at this point in the history
…k on entering 360)
  • Loading branch information
Kevin Staunton-Lambert committed Dec 20, 2022
1 parent 856a183 commit 7c0c62b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 4 additions & 5 deletions src/big-vr-play-button.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import videojs from 'video.js';
import window from 'global/window';

const BigPlayButton = videojs.getComponent('BigPlayButton');

Expand All @@ -9,18 +10,16 @@ class BigVrPlayButton extends BigPlayButton {

handleClick() {
// For iOS we need permission for the device orientation data, this will pop up an 'Allow' if not already set
if (window.typeof(DeviceMotionEvent) === 'function' && typeof(window.DeviceMotionEvent.requestPermission) === "function") {
// eslint-disable-next-line
if (typeof(window.DeviceMotionEvent) === 'function' && typeof(window.DeviceMotionEvent.requestPermission) === "function") {
window.DeviceMotionEvent.requestPermission().then(response => {
if (response !== 'granted') {
this.log("DeviceMotionEvent permissions not set");
this.log('DeviceMotionEvent permissions not set');
}
});
}

super.handleClick();
}


}

videojs.registerComponent('BigVrPlayButton', BigVrPlayButton);
Expand Down
7 changes: 5 additions & 2 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class VR extends Plugin {
this.scene.add(this.movieScreen);

const ambient = new THREE.HemisphereLight(0xffffff, 0xbbbbff, 0.7);

this.scene.add(ambient);
} else if (projection === '360_LR' || projection === '360_TB') {
// Left eye view
Expand Down Expand Up @@ -802,8 +803,10 @@ void main() {
window.addEventListener('vrdisplaydeactivate', this.handleVrDisplayDeactivate_, true);

// For iOS we need permission for the device orientation data, this will pop up an 'Allow'
if (window.typeof(DeviceMotionEvent) === 'function' && typeof(window.DeviceMotionEvent.requestPermission) === "function") {
// eslint-disable-next-line
if (typeof(window.DeviceMotionEvent) === 'function' && typeof(window.DeviceMotionEvent.requestPermission) === "function") {
const self = this;

window.DeviceMotionEvent.requestPermission().then(response => {
if (response === 'granted') {
window.addEventListener('deviceorientation', (event) => {
Expand All @@ -818,7 +821,7 @@ void main() {
}

onDeviceOrientationChange(pitch, roll, yaw) {
this.log(`orientation pitch=${parseInt(pitch)} roll=${parseInt(roll)} yaw=${parseInt(yaw)}`);
this.log(`orientation pitch=${parseInt(pitch, 10)} roll=${parseInt(roll, 10)} yaw=${parseInt(yaw, 10)}`);
}

buildControllers() {
Expand Down

0 comments on commit 7c0c62b

Please sign in to comment.