Skip to content

Commit

Permalink
(testing aliasing)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Staunton-Lambert committed Aug 15, 2024
1 parent 8f32f19 commit d341f83
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 18 deletions.
2 changes: 1 addition & 1 deletion examples/180-hls.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link href="../dist/videojs-vr.css" rel="stylesheet">
</head>
<body>
<video width="640" height="300" id="videojs-vr-player" class="video-js vjs-default-skin" controls playsinline>
<video width="3840" height="3840" id="videojs-vr-player" class="video-js vjs-default-skin" controls playsinline>
<source src="https://kevleyski.github.io/reckless_in_pyrmont/hls_fmp4_byterange/reckless_in_pyrmont.m3u8" type="application/vnd.apple.mpegurl">
</video>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion examples/180-mono.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link href="../dist/videojs-vr.css" rel="stylesheet">
</head>
<body>
<video width="640" height="300" id="videojs-vr-player" class="video-js vjs-default-skin" controls playsinline>
<video width="3840" height="3840" id="videojs-vr-player" class="video-js vjs-default-skin" controls playsinline>
<source src="../samples/video_180_lefteyeonly.mp4" type="video/mp4">
</video>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion examples/180-tb.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link href="../dist/videojs-vr.css" rel="stylesheet">
</head>
<body>
<video width="640" height="300" id="videojs-vr-player" class="video-js vjs-default-skin" controls playsinline>
<video width="3840" height="3840" id="videojs-vr-player" class="video-js vjs-default-skin" controls playsinline>
<source src="../samples/video_180_TB.mp4" type="video/mp4">
</video>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion examples/180.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link href="../dist/videojs-vr.css" rel="stylesheet">
</head>
<body>
<video width="640" height="300" id="videojs-vr-player" class="video-js vjs-default-skin" controls playsinline>
<video width="3840" height="3840" id="videojs-vr-player" class="video-js vjs-default-skin" controls playsinline>
<source src="../samples/video_180.mp4" type="video/mp4">
</video>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion examples/360-cube.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link href="../dist/videojs-vr.css" rel="stylesheet">
</head>
<body>
<video width="640" height="300" id="videojs-vr-player" class="video-js vjs-default-skin" controls playsinline>
<video width="3840" height="3840" id="videojs-vr-player" class="video-js vjs-default-skin" controls playsinline>
<source src="../samples/doisethup_cubemap.mp4" type="video/mp4">
</video>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion examples/360-sphere-detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link href="../dist/videojs-vr.css" rel="stylesheet">
</head>
<body>
<video width="640" height="300" id="videojs-vr-player" class="video-js vjs-default-skin" controls playsinline>
<video width="3840" height="3840" id="videojs-vr-player" class="video-js vjs-default-skin" controls playsinline>
<source src="../samples/eagle-360.mp4" type="video/mp4">
</video>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion examples/360-tb-2.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<link href="../dist/videojs-vr.css" rel="stylesheet">
</head>
<body>
<video width="640" height="300" id="videojs-vr-player" class="video-js vjs-default-skin" controls playsinline>
<video width="3840" height="3840" id="videojs-vr-player" class="video-js vjs-default-skin" controls playsinline>
<source src="../samples/cc_oceanside_beach.mp4" type="video/mp4">
</video>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion examples/360-tb.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</head>
<body>
<p>TB Equirectangular video</p>
<video width="640" height="300" id="videojs-vr-player-rect2" class="video-js vjs-default-skin" controls playsinline>
<video width="3840" height="3840" id="videojs-vr-player-rect2" class="video-js vjs-default-skin" controls playsinline>
<source src="../samples/coriolis_rect.webm" type="video/webm">
</video>
<p>Credits: Animations for Physics and Astronomy, CC-BY-3.0</p>
Expand Down
2 changes: 1 addition & 1 deletion examples/360-two.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link href="../dist/videojs-vr.css" rel="stylesheet">
</head>
<body>
<video width="640" height="300" id="videojs-vr-player" class="video-js vjs-default-skin" controls playsinline>
<video width="3840" height="3840" id="videojs-vr-player" class="video-js vjs-default-skin" controls playsinline>
<source src="../samples/lcs15_rect.webm" type="video/mp4">
</video>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion examples/360.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link href="../dist/videojs-vr.css" rel="stylesheet">
</head>
<body>
<video width="640" height="300" id="videojs-vr-player" class="video-js vjs-default-skin" controls playsinline>
<video width="3840" height="3840" id="videojs-vr-player" class="video-js vjs-default-skin" controls playsinline>
<source src="../samples/eagle-360.mp4" type="video/mp4">
</video>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion examples/disable-togglePlay.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link href="../dist/videojs-vr.css" rel="stylesheet">
</head>
<body>
<video width="640" height="300" id="videojs-vr-player" class="video-js vjs-default-skin" crossorigin="anonymous" controls playsinline>
<video width="3840" height="3840" id="videojs-vr-player" class="video-js vjs-default-skin" crossorigin="anonymous" controls playsinline>
<source src="https://storage.googleapis.com/omnitone-demo.google.com.a.appspot.com/fuerza-imprevista-1080p-h264-aac.mp4" type="video/mp4">
</video>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion examples/eac-lr.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</head>
<body>
<p>LR EAC video</p>
<video width="640" height="300" id="videojs-vr-player-eac-lr" class="video-js vjs-default-skin" controls playsinline>
<video width="3840" height="3840" id="videojs-vr-player-eac-lr" class="video-js vjs-default-skin" controls playsinline>
<source src="../samples/coriolis_eac.webm" type="video/webm">
</video>
<p>Credits: Animations for Physics and Astronomy, CC-BY-3.0</p>
Expand Down
2 changes: 1 addition & 1 deletion examples/spatial.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link href="../dist/videojs-vr.css" rel="stylesheet">
</head>
<body>
<video width="640" height="300" id="videojs-vr-player" class="video-js vjs-default-skin" crossorigin="anonymous" controls playsinline>
<video width="3840" height="3840" id="videojs-vr-player" class="video-js vjs-default-skin" crossorigin="anonymous" controls playsinline>
<source src="https://storage.googleapis.com/omnitone-demo.google.com.a.appspot.com/fuerza-imprevista-1080p-h264-aac.mp4" type="video/mp4">
</video>
<ul>
Expand Down
46 changes: 41 additions & 5 deletions src/big-vr-play-button.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import videojs from 'video.js';
import window from 'global/window';

let xrMediaFactory = null;

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

class BigVrPlayButton extends BigPlayButton {
Expand All @@ -10,28 +12,62 @@ class BigVrPlayButton extends BigPlayButton {

async onSessionStarted(session) {
await window.navigator.xr.setSession(session);

xrMediaFactory = new global.XRMediaBinding(session);
session.requestReferenceSpace('local').then((refSpace) => {
const player = videojs.getAllPlayers()[0];

if (player) {
const video = player.tech({IWillNotUseThisInPlugins: true}).el();

if (player.mediainfo && player.mediainfo.projection) {
const is360 = player.mediainfo.projection.indexOf('360') !== -1;

if (player.mediainfo.projection.indexOf('MONO') !== -1) {
const layer = xrMediaFactory.createEquirectLayer(video, {
space: refSpace,
centralHorizontalAngle: (is360) ? Math.PI * 2 : Math.PI,
layout: 'mono'
});

session.updateRenderState({layers: [layer]});
player.isUsingLayers = true;
} else {
const isTopBottom = player.mediainfo.projection.indexOf('TB') !== -1;

const layer = xrMediaFactory.createEquirectLayer(video, {
space: refSpace,
centralHorizontalAngle: (is360) ? Math.PI * 2 : Math.PI,
layout: (isTopBottom) ? 'stereo-top-bottom' : 'stereo-left-right'
});

session.updateRenderState({layers: [layer]});
player.isUsingLayers = true;
}
}
}
});
}

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

if (window.navigator.xr && window.navigator.xr.requestSession) {
if (window.navigator.xr) {
const sessionInit = {optionalFeatures: ['local-floor', 'bounded-floor', 'hand-tracking']};
const self = this;

window.navigator.xr.requestSession('immersive-vr', sessionInit).then(self.onSessionStarted).catch(_ => {
// immersive-vr not supported
});
window.navigator.xr.requestSession('immersive-vr', sessionInit).then(self.onSessionStarted).catch();
}

super.handleClick(event);
}
}
Expand Down

0 comments on commit d341f83

Please sign in to comment.