Skip to content

Commit

Permalink
KJSL: Reviving DeviceOrientationControls for iPhone
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Staunton-Lambert committed Jul 30, 2024
1 parent e00f3a9 commit 26c4ef1
Showing 1 changed file with 33 additions and 25 deletions.
58 changes: 33 additions & 25 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class VR extends Plugin {
this.handleVrDisplayDeactivate_ = videojs.bind(this, this.handleVrDisplayDeactivate_);
this.handleResize_ = videojs.bind(this, this.handleResize_);
this.animate_ = videojs.bind(this, this.animate_);
this.handleUserActive_ = videojs.bind(this, this.handleUserActive_);

this.setProjection(this.options_.projection);

Expand Down Expand Up @@ -515,7 +516,7 @@ void main() {
// if we have videojs-errors use it
if (this.videojsErrorsSupport_) {
this.player_.error(errorObj);
// if we don't have videojs-errors just use a normal player error
// if we don't have videojs-errors just use a normal player error
} else {
// strip any html content from the error message
// as it is not supported outside of videojs-errors
Expand Down Expand Up @@ -564,6 +565,12 @@ void main() {

}

handleUserActive_() {
if (this.webVREffect) {
this.webVREffect.isPresenting = true;
}
}

requestAnimationFrame(fn) {
if (this.vrDisplay) {
return this.vrDisplay.requestAnimationFrame(fn);
Expand Down Expand Up @@ -659,7 +666,6 @@ void main() {
// this.controls3d.orbit.target.setY(this.camera.quaternion.y);
// this.controls3d.orbit.target.setZ(this.camera.quaternion.z);
this.controls3d.orbit.update();
this.webVREffect.isPresenting = true;
}
}

Expand Down Expand Up @@ -878,6 +884,7 @@ void main() {
window.addEventListener('resize', this.handleResize_, true);
window.addEventListener('vrdisplayactivate', this.handleVrDisplayActivate_, true);
window.addEventListener('vrdisplaydeactivate', this.handleVrDisplayDeactivate_, true);
window.addEventListener('pointerdown', this.handleUserActive_, true);

// For iOS we need permission for the device orientation data, this will pop up an 'Allow'
// eslint-disable-next-line
Expand Down Expand Up @@ -1119,29 +1126,29 @@ void main() {
this.highlight.visible = true;
if (controller.userData.selectPressed) {
switch (rayTargets[0].object.buttonid) {
case 'playpause':
this.togglePlay_();
break;

case 'back10':
this.seekBack10_();
break;

case 'forward10':
this.seekForward10_();
break;

case 'controller':
// TODO: drag move controller bar?
break;

case 'exit':
this.vrButton.click();
if (this.currentSession) {
this.currentSession.end();
this.player_.pause();
}
break;
case 'playpause':
this.togglePlay_();
break;

case 'back10':
this.seekBack10_();
break;

case 'forward10':
this.seekForward10_();
break;

case 'controller':
// TODO: drag move controller bar?
break;

case 'exit':
this.vrButton.click();
if (this.currentSession) {
this.currentSession.end();
this.player_.pause();
}
break;
}
controller.userData.selectPressed = false;
}
Expand Down Expand Up @@ -1257,6 +1264,7 @@ void main() {
window.removeEventListener('vrdisplaypresentchange', this.handleResize_, true);
window.removeEventListener('vrdisplayactivate', this.handleVrDisplayActivate_, true);
window.removeEventListener('vrdisplaydeactivate', this.handleVrDisplayDeactivate_, true);
window.removeEventListener('pointerdown', this.handleUserActive_, true);

// re-add the big play button to player
if (!this.player_.getChild('BigPlayButton')) {
Expand Down

0 comments on commit 26c4ef1

Please sign in to comment.