Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

videojs-vr

videojs21.2kMIT2.0.0

A plugin to add 360 and VR video support to video.js.

videojs, videojs-plugin

readme

VR

https://videojs-vr.netlify.com

Build Status Greenkeeper badge Slack Status Netlify Status

NPM

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

npm i videojs-vr

Browser Support

The most recent versions of:

  • Desktop
    • Chrome
    • Firefox
    • Safari
  • Mobile
    • Chrome on Android
    • Safari on iOS

Caveats

  • HLS captions on safari will not be visible as they are located inside of the shadowRoot in the video element and we cannot get access to them.

Projection support

Currently we only support:

  • Projections
    • Spherical Videos, via the 360/equirectangular projection
    • 360 cube videos
  • Mappings
    • Monoscopic (single video pane)
    • Stereoscopic (dual video pane for both eyes) via the cardboard button

      Usage

To include videojs-vr on your website or web application, use any of the following methods.

<script> Tag

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.

<script src="//path/to/video.min.js"></script>
<script src="//path/to/videojs-vr.min.js"></script>
<script>
  var player = videojs('my-video');

  player.vr();
</script>

Browserify/CommonJS

When using with Browserify, install videojs-vr via npm and require the plugin as you would any other module.

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'});

RequireJS/AMD

When using with RequireJS (or another AMD library), get the script in whatever way you prefer and require the plugin as you normally would:

require(['video.js', 'videojs-vr'], function(videojs) {
  var player = videojs('my-video');

  player.vr({projection: '360'});
});

Optional integration with videojs-errors

If the videojs-errors plugin is intialized before videojs-vr, 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:


var player = videojs('my-video');

player.vr({projection: '360'});

// or change player.vr.defaultProjection
// and call player.vr.initScene again

Passing a projection on a source by source basis

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:

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.

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.

var player = videojs('my-video');

player.vr().camera;
player.vr().scene;
player.vr().renderer;

Options

forceCardboard

Type: boolean, default: false

Force the cardboard button to display on all devices even if we don't think they support it.

motionControls

Type: boolean, default: true on ios and andriod

Whether motion/gyro controls should be enabled.

projection

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

sphereDetail

type: number, default: 32

This 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.

player.mediainfo.projection

type: string

This should be set on a source-by-source basis to turn 360 videos on an off depending upon the video.

See projection above for information of values. Note that AUTO is the same as NONE for player.mediainfo.projection.

debug

type: boolean, default: false

Enable debug logging for this plugin

omnitone

type: Omnitone library object

Use 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.

omnitoneOptions

type: object, default: {}

Default options for the Omnitone library. Please check available options on https://github.com/GoogleChrome/omnitone

disableTogglePlay

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.

Credits

This project is a conglomeration of a few amazing open source libraries.

Support

This work is sponsored by Brightcove, HapYak and StreamShark

changelog

2.0.0 (2023-02-15)

Chores

  • update build tooling to drop older browser support (#276) (0947a0f)

BREAKING CHANGES

  • This drops support for older browsers such as IE

1.10.1 (2022-08-16)

Chores

Documentation

  • add caveats section for safari (eb80c8a)

1.10.0 (2021-08-31)

Chores

  • skip syntax check with vjsverify due to three (#249) (3d9df3c)

1.9.0 (2021-08-31)

Features

Chores

1.8.0 (2021-06-15)

Features

  • Add an option to prevent clicks from toggling playback (#239) (7dc2684)
  • add option to change the detail level of the projection sphere (#225) (9293eb4)

Bug Fixes

  • include edited three.js examples in module dist files (#238) (93bec48)
  • separate 180_LR/180_TB, add 180_MONO, fix cropping in 180 views. (91b7963)

Chores

  • fix publish by skipping require verification (360abb7)
  • update dependencies, readme, examples, and switch to github actions ci (#242) (bf97c5b)

Documentation

1.7.2 (2020-03-03)

Bug Fixes

  • null check fullscreen toggle to fix ios without it (#197) (24f2483)

1.7.1 (2019-11-18)

Bug Fixes

  • increase touchmove threshold for "taps" on mobile (#190) (4e92c33)

Chores

  • add generator-helper deps back in (0b8a8cd)
  • add lint-staged as dev-dep (4844494)
  • fixup package-lock urls (2ba689d)

1.7.0 (2019-09-09)

Features

  • Add support for Spatial audio rendering via Omnitone (#181) (2af9aa3)

1.6.1 (2019-09-05)

Bug Fixes

  • build css files before publish (9a85fc9)

1.6.0 (2019-08-28)

Features

Bug Fixes

  • Prevent switching to lowest resolution HLS resolution, due to non-displayed video (#177) (7338726)

Chores

  • package: update npm-run-all to 4.1.5 (#160) (b2ee794)

Documentation

  • Fix JavaScript highlight in README.md (#143) (dd73e51)
  • update examples and readme (2440f77)

Tests

  • Add a test, fix the build, update generator version (#184) (17c7ee0)

1.5.0 (2018-09-17)

Features

Bug Fixes

  • Remove the postinstall script to prevent install issues (#134) (d6d9ac0)

Chores

  • update to generator-videojs-plugin@7.2.0 (634be2b)
  • package: update videojs-generate-rollup-config to version 2.2.0 🚀 (#135) (d42d1f2)

1.4.7 (2018-08-23)

Chores

1.4.6 (2018-08-08)

Chores

1.4.5 (2018-08-03)

Bug Fixes

  • babel the es dist, by updating the generator (#117) (2d4468d)

1.4.4 (2018-08-01)

Bug Fixes

  • dispose event listeners on window correctly (#119) (b6a8125)

1.4.3 (2018-07-20)

Bug Fixes

1.4.2 (2018-07-05)

Chores

1.4.1 (2018-06-18)

Bug Fixes

  • ios sizing issue when deactivating vr display (#104) (3a83a05)

1.4.0 (2018-06-08)

Bug Fixes

  • hide control bar while moving, allow clicking to play/pause, allow right click (#96) (21b66ca)

Chores

  • package: update rollup and rollup-plugin-json (#93) (33db8a8)

1.3.0 (2018-05-23)

Features

  • handle 360_CUBE projection (thanks dillontiner!) (#86) (19ae76d)

Bug Fixes

  • FrontSide -> BackSide for 360 videos due to changes in three.js (#88) (e58862d)
  • no rotate instructions and ios back arrow fix (#75) (0c525cd)
  • re-implement touch pan controls (#89) (0cde016)
  • remove safari video image canvas work-around (#74) (4a9d500)
  • vjs fluid class usage, and remove hacky mutationobserver work-around (#76) (db749dc)

Chores

  • package: update rollup to version 0.58.2 (#77) (a4d611f)
  • package: update rollup-plugin-babel to version 3.0.4 (#70) (7ae874a)
  • package: update rollup-plugin-commonjs to version 9.1.3 (#79) (90d5fb6)
  • package: update three to version 0.92.0 (#78) (b9668cb)

Documentation

  • remove webvr-boilerplate from the readme (a2015e1)

1.2.1 (2018-05-08)

Bug Fixes

  • Correctly show an error in IE/Safari when webvr is unsupported (#67) (67988da)

1.2.0 (2018-03-27)

Bug Fixes

  • chrome m55 android gyro breakage by updating webvr-polyfill (#64) (ff8e461)

Chores

  • package: update rollup to version 0.57.1 (#62) (d81a5a4), closes #57

1.1.1 (2018-02-20)

Bug Fixes

  • expose version correctly (#51) (dd7adc1)
  • OrbitControls: no pan, less speed, no zoom (#52) (44b6d41)
  • rework three example build, to fix webpack (#53) (382156b)

1.1.0 (2018-01-31)

Features

  • remove threejs files from the repo (#43) (a5cf671)

Bug Fixes

1.0.3 (2017-12-04)

Bug Fixes

  • workaround for firefox/polyfill display issue (#41) (76e6e03)

1.0.2 (2017-10-19)

Bug Fixes

1.0.1 (2017-08-29)

Bug Fixes

  • equirectangular should be equivelent to 360 (#28) (f0e5422)

Chores

1.0.0 (2017-08-24)

Features

  • add an option to force cardboard button (#20) (1dee5f7)
  • expose more of vrs methods (#10) (3cc1092)

Bug Fixes

  • add a cardboard button for native webvr support (#22) (e946219)
  • auto projection should be set to the correct value and not auto (#4) (377e8a6)
  • cleanup window listeners (#15) (d3e45ad)
  • correctly check for cardboard button on control bar so we don't add two (#26) (9184472)
  • encode svg in css, use exact button replacement size (#3) (9a37374)
  • make cardboard button pseudo fullscreen on iOS (#12) (17a41c0)
  • pin webvr-polyfill to 0.9.23 (#21) (a644d1e)
  • pixelation issues on some devices (#17) (6f09814)
  • prevent initialization from happening twice (#9) (33deadc)
  • separate and reset CardboardButton and BigVrPlayButton (#11) (3ae105e)
  • use player fullscreenchange event so fullscreen toggle works on Safari (#2) (05c0f23)