logo
THEOplayer
ABR
Ads
Caching
Content protection
Analytics
Casting
Media and Text Tracks
Miscellaneous
Verizon Media
Source
Events
SSAI
Network
Presentation
Player
UI
VR
VRConfigurationVRDirectionVRVREventMapVRStereoModeVRState

THEOplayer > VR

VR interface

Inherits from EventDispatcher<VREventMap> . See parent page for inherited properties and methods.

The virtual reality API which allows you to control the display of 360° VR videos.

Signature:

export interface VR extends EventDispatcher<VREventMap> 

Remarks


- See VRConfiguration to configure a source.
- The player utilises the Canvas API internally to render 360° content and is restricted to the same limitations.
- To access devicemotion events on mobile devices, a page needs to be served over https on modern browsers.
- To access devicemotion events on Safari for iOS 13+ you need to request user permission using the DeviceMotionEvent.requestPermission API
- iPhone support requires iOS 10: On iOS 9 and lower, iPhone forces HTML5 video to play in fullscreen. As a result, the canvas used by THEOplayer VR will not be visible during playback, since it will be behind the fullscreen video. iPhone users must upgrade to iOS 10 or higher for the full VR experience. Note that iPad is unaffected: VR is supported even on iOS 9 and lower.
- Cross-origin iframes on iOS: iOS blocks cross-origin iframes from accessing devicemotion events WebKit bug #152299. As a result, when using THEOplayer inside a cross-origin iframe, the player cannot rotate the VR display to align with the device's physical orientation. Fortunately, this can be worked around by listening for devicemotion events on the top frame and forwarding them as messages to the iframe. THEOplayer will automatically handle these messages as if they were native devicemotion events:

Example

const playerIframe = document.querySelector('iframe');
window.addEventListener('devicemotion', function (event) {
   playerIframe.contentWindow.postMessage({
       type : 'devicemotion',
       deviceMotionEvent : {
           acceleration : event.acceleration,
           accelerationIncludingGravity : event.accelerationIncludingGravity,
           interval : event.interval,
           rotationRate : event.rotationRate,
           timeStamp : event.timeStamp
       }
   }, '*');
});

Properties

Property

Type

Description

canPresentVR

boolean

Whether the player can present in VR mode.

direction

VRDirection

The viewing direction.

state

VRState

The state of the VR feature.

stereo

boolean

Whether stereo mode is enabled.

verticalFOV

number

The vertical field of view in VR, in degress.

Property Details

canPresentVR

Whether the player can present in VR mode.

Signature:

readonly canPresentVR: boolean;

direction

The viewing direction.

Signature:

direction: VRDirection;

state

The state of the VR feature.

Signature:

readonly state: VRState;

stereo

Whether stereo mode is enabled.

Signature:

stereo: boolean;

Remarks


- Setting it to true renders the video in VR.

verticalFOV

The vertical field of view in VR, in degress.

Signature:

verticalFOV: number;

Remarks


- It should be a number in the range of [0, 180].

github
Make sure to follow us on GitHub!
THEO-logo-white
twitter
facebook
linkedin
Copyright © 2020. All Rights Reserved.
Leuven
New York
San Francisco
Singapore
Barcelona