A plugin to add 360 and VR video support to video.js.
npm install videojs-vrhttps://videojs-vr.netlify.com





A video.js plugin that turns a video element into a HTML5 Panoramic 360 video player. Project video onto different shapes. Optionally supports Oculus Rift, HTC Vive and the GearVR.
Lead Maintainer: Brandon Casey @brandonocasey
Maintenance Status: Stable
- Installation
- Browser Support
- Caveats
- Projection support
- Usage
- Tag
- Browserify/CommonJS
- RequireJS/AMD
- Optional integration with videojs-errors
- Setting a global projection
- Passing a projection on a source by source basis
- Oculus Rift and HTC Vive Support
- Accessing the Camera Position
- Accessing THREE.js objects
- Options
- forceCardboard
- motionControls
- projection
- '180'
- '180_LR'
- '180_MONO'
- '360', 'Sphere', or 'equirectangular'
- 'Cube' or '360_CUBE'
- 'NONE'
- 'AUTO'
- '360_LR'
- '360_TB'
- 'EAC'
- 'EAC_LR'
- sphereDetail
- player.mediainfo.projection
- debug
- omnitone
- omnitoneOptions
- disableTogglePlay
- Credits
- Support
``sh`
npm i videojs-vr
To include videojs-vr on your website or web application, use any of the following methods.
This is the simplest case. Get the script in whatever way you prefer and include the plugin _after_ you include [video.js][videojs], so that the videojs global is available.
`html`
When using with Browserify, install videojs-vr via npm and require the plugin as you would any other module.
`js
var videojs = require('video.js');
// The actual plugin function is exported by this module, but it is also
// attached to the Player.prototype; so, there is no need to assign it
// to a variable.
require('videojs-vr');
var player = videojs('my-video');
player.vr({projection: '360'});
`
When using with RequireJS (or another AMD library), get the script in whatever way you prefer and require the plugin as you normally would:
`js
require(['video.js', 'videojs-vr'], function(videojs) {
var player = videojs('my-video');
player.vr({projection: '360'});
});
`
, then it will be used to display errors to users.Setting a global projection
If you are only going to be playing 360 videos you can set the global plugin projection like so:`jsvar player = videojs('my-video');
player.vr({projection: '360'});
// or change player.vr.defaultProjection
// and call player.vr.initScene again
`$3
Set player.mediainfo and player.mediainfo.projection to a valid projection value and pass in 'AUTO' or nothing for the projection key when initializing this plugin.
EX:
`js
var player = videojs('my-video');if (!player.mediainfo) {
player.mediainfo = {};
}
if (!player.mediainfo.projection) {
player.mediainfo.projection = '360';
}
player.vr({projection: 'AUTO'});
// or player.vr(); since 'AUTO' is the default
`Oculus Rift and HTC Vive Support
This project leverages the webvr-polyfill and three.js libraries to create a 'responsive VR' experience across multiple devices.Oculus Rift and HTC Vive playback requires Firefox >= 55, experimental WebVR-enabled builds of Chromium, or via Chrome by enabling webvr in
chrome://flags. Go to WebVR.info for more info.GearVR playback requires the latest Samsung Internet for Gear VR with WebVR support enabled. Go here for more info.
Accessing the Camera Position
The Three.js rotation values are exposed under the property cameraVector on the vr plugin namespace.`js
var player = videojs('my-video');player.vr().cameraVector;
`Accessing THREE.js objects
The Three.js Scene, renderer, and perspective camera are exposed under the threeJs object as the properties scene, renderer, and camera on the vr plugin namespace.`js
var player = videojs('my-video');player.vr().camera;
player.vr().scene;
player.vr().renderer;
`Options
$3
> Type: boolean, default: falseForce the cardboard button to display on all devices even if we don't think they support it.
$3
> Type: boolean, default: true on ios and andriodWhether motion/gyro controls should be enabled.
$3
> Type
string, default: 'auto'
Can be any of the following:####
'180'
The video is half sphere and the user should not be able to look behind themselves####
'180_LR'
Used for side-by-side 180 videos
The video is half sphere and the user should not be able to look behind themselves####
'180_MONO'
Used for monoscopic 180 videos
The video is half sphere and the user should not be able to look behind themselves####
'360', 'Sphere', or 'equirectangular'
The video is a sphere####
'Cube' or '360_CUBE'
The video is a cube####
'NONE'
This video is not a 360 video####
'AUTO'
Check player.mediainfo.projection to see if the current video is a 360 video.####
'360_LR'
Used for side-by-side 360 videos####
'360_TB'
Used for top-to-bottom 360 videos####
'EAC'
Used for Equi-Angular Cubemap videos####
'EAC_LR'
Used for side-by-side Equi-Angular Cubemap videos$3
> type:
number, default: 32This alters the number of segments in the spherical mesh onto which equirectangular
videos are projected. The default is
32 but in some circumstances you may notice
artifacts and need to increase this number.$3
> type:
stringThis should be set on a source-by-source basis to turn 360 videos on an off depending upon the video.
projection above for information of values. Note that AUTO is the same as NONE for player.mediainfo.projection.$3
> type:
boolean, default: falseEnable debug logging for this plugin
$3
> type:
Omnitone library objectUse this property to pass the Omnitone library object to the plugin.
Please be aware of, the Omnitone library is not included in the build files.
$3
> type:
object, default: {}Default options for the Omnitone library. Please check available options on https://github.com/GoogleChrome/omnitone
$3
> type:
boolean, default: false`Feature to disable the togglePlay manually.
This functionality is useful in live events so that users cannot stop the live, but still have a controlBar available.
This project is a conglomeration of a few amazing open source libraries.
* VideoJS
* Three.js
* webvr-polyfill
* Omnitone