This article will show you how to play a VR source in THEOplayer using WebXR. If you are not familiar with THEOplayer, we strongly recommend reading the getting started documentation for web first.
Web SDK | Android SDK | iOS SDK | tvOS SDK | Android TV SDK | Chromecast SDK |
---|---|---|---|---|---|
Yes | No | No | No | No | No |
Older versions of THEOplayer will work with regular VR, but not with WebXR.
vr-webxr
feature enabled.You can quickly check using THEOplayer.features
.
Notice: The official polyfill has a bug in its rendering. THEOplayer has proposed a fix, but it has not yet merged into the main project. In the meanwhile you can use a patched build from our CDN. We highly recommend you to download this patch, since it will no longer be available when the main polyfill is fixed.
Add the polyfill to your page:
<script src="//cdn.theoplayer.com/webxr/webxr-polyfill-patched.js"></script>
And enable it:
const POLYFILL_CONFIG = {
allowCardboardOnDesktop: true
};
new WebXRPolyfill(POLYFILL_CONFIG);
The default behavior for THEOplayer is to use regular VR, so make sure to add the following VR configuration to
your PlayerConfiguration
:
const playerConfig: PlayerConfiguration = {
// ...
vr: {
useWebXR: true
}
}
You can set the following source to test:
player.source = {
sources: {
src: "//demo.theoplayer.com/hubfs/videos/natgeo/playlist.m3u8",
crossOrigin: "anonymous",
},
vr: {
panoramaMode: "360",
stereoMode: "none",
},
poster: "//demo.theoplayer.com/hubfs/videos/natgeo/poster.jpg",
}
If everything went well, you should now be using WebXR!