Class s7sdk.video.Video360Player
The Video360Player
is a 360-degree video viewing component that displays a MP4 or Adaptive Video Set video served by Adobe Scene7.
360-degree videos, also known as immersive videos or spherical videos, are video recordings where a view in every direction is recorded at the
same time, shot using an omnidirectional camera or a collection of cameras.
Depending on system capabilities and on the value of the playback
modifier, it uses either hls-video or the native HTML video element.
HTTP streaming video is used whenever the user's device supports it, with fall back to progressive video.
The component supports 360 video with aspect ratio of 2:1 only. Spatial sound is not supported. Video360Player
is designed to work
with with 360 video only; an attempt to play a non-360 video will result in distorted video playback.
Video playback is controlled by clicking (or tapping) on the video if enabled using a singleClick
modifier, or by using API methods and external video UI controls supplied with the SDK, such as
ControlBar
, PlayPauseButton
, FullScreenButton
, MutableVolume
and VideoScrubber
.
Panning of 360-video is done with the mouse, swipe gestures on touch device or using arrow keys.
Information about the video and the state of the video playback can be obtained from the various VideoEvent
events dispatched by the Video360Player
, and/or the methods available in its API. For example,
video duration can be obtained using the getDuration()
method and/or by handling the NOTF_DURATION
event; the current play head position is available through the getCurrentTime()
method and the NOTF_CURRENT_TIME
and NOTF_SEEK
events; the state of the media preloading (in progressive mode) can be read via the getLoadedPosition()
method and the NOTF_LOAD_PROGRESS
event. Current volume can be retrieved using the
getVolume()
method and the NOTF_VOLUME
event.
The component also dispatches a convenience CapabilityStateEvent.NOTF_VIDEO_CAPABILITY_STATE
events whenever any of video capabilities listed in VideoCapabilityState
changes.
This event in particular is very useful for controlling the state of external UI controls like PlayPauseButton
.
The Video360Player
component provides a convenience API for describing underlying system restrictions related to video playback. The supportsInline()
method identifies whether the system can
play video inline; in the case when inline playback is not possible (like on some mobile phones), external UI elements like VideoScrubber
are not needed on the page. The supportsVolumeControl()
tells whether programmatic volume control is possible; on mobile devices volume is normally controlled using hardware buttons only, so MutableVolume
should be hidden in that case.
In order to implement a full screen video experience, the Video360Player
should be embedded into the Container
component; Container
provides an API and support for
full screen mode.
The Video360Player
component supports playback of video content hosted outside of Scene7 or Dynamic Media. If the path portion
of URL to such external video ends with .m3u8
then the component automatically selects HLS playback type, otherwise progressive playback
will be used. Effectively Video360Player
ignores the value of playback
modifier when working with external video. External video
can be set using video
modifier or setVideo()
API method.
The Video360Player
component supports 360 video playback on VR headsets (like Oculus Go and Oculus Rift), VR HMD (head-mounted display) mounts (like Google Cardboard) and non-VR enabled devices (like desktop browsers, tablets and mobile phones not connected to VR HMD mounts).
No additional configuration is needed to view video content on VR headset. The component automatically detects the presence of VR headset and shows "VR" button on top of video content.
Activating this "VR" button switches video rendering to VR mode. The component supports VR rendering only in browsers with WebVR support. vrrender
modifier is ignored when running on VR headset.
In order to use VR HMD mounts however vrrender
modifier must be set to "1" in component's configuration, which forces stereoscopic rendering.
On VR headsets and VR HMD mounts point of view change happens in response to headset movement, not other playback control is provided in VR mode.
When watching 360 video on non-VR enabled devices, end user can use mouse, touch or keyboard to control video playback and point of view.
Customizing Behavior Using Modifiers
Modifiers change Video360Player
default behavior. They are passed to the component by the ParameterManager
instance
specified in the constructor.
The following modifiers are supported:
Modifier | Syntax | Description | Default |
serverurl | isRootPath | The Image Serving root path. If no domain is specified, the domain from which the page is served is applied instead. Standard URI path resolution applies. | /is/image/ |
videoserverurl | videoRootPath | The video server root path. If no domain is specified, the domain from which the page is served is applied instead. Standard URI path resolution applies. | /is/content/ |
contenturl | contentRootPath | The content root path. If no domain is specified, the domain from which the page is served is applied instead. Standard URI path resolution applies. | /is/content/ |
asset | value | The asset ID of the single video or Adaptive Video Set. | "" |
autoplay | 0|1 | Indicates whether the component starts playing the video when the load operation is successfully completed. Some systems, such as certain mobile devices, may not support autoplay. | 1 |
iconeffect | 0|1[,count][,fade][,autoHide] | Enables the IconEffect to display on top of the video when the video is in a paused state. Set count to specify the maximum number of times the icon overlay appears and reappears. A value of -1 indicates that the overlay reappears indefinitely. Set fade to specify the duration in seconds of show or hide animation. Set autoHide to specify the number of seconds that the IconEffect stays fully visible before it auto-hides. That is, the time after fade in animation is completed and before fade out animation starts. A setting of 0 disables auto-hide behavior. | 1,1,0.3,3 |
singleclick | none|playPause | Configures the mapping of single-click or tap-to-toggle play/pause. Set to none to disable single-click or tap-to-play/tap-to-pause. If set to playPause , clicking the video toggles between playing and pausing the video. | playPause |
playback | auto|progressive | Sets the type of playback used by the component. If progressive is specified, the component only relies on HTML5 playback as natively supported by browsers. If auto is specified, the component use HLS-playback. For more information on the playback selection in auto and progressive modes, see the HTML5 Viewers SDK User Guide. | auto |
progressivebitrate | value | Specifies--in kbits per second or kbps--the desired video bit rate to play from the Adaptive Video Set in case the current system does not support adaptive video playback. The component picks up the video stream with the closest possible--but not exceeding--bit rate to the specified value. If all video streams in the Adaptive Video Set have higher quality than the specified value, the logic chooses the bit rate with the lowest quality. | 700 |
initialbitrate | value | Sets the bit rate of the video that the video player starts to look for in the Adaptive Video Set. If the value does not exist in the Adaptive Video Set, the video player starts with the video that has the next lowest bit rate. If set to 0 , the video player starts from the lowest possible bit rate. Applicable only for desktop browsers that use software HLS playback when the playback modifier is set to auto . On slow connections high bitrate settings may be ignored by the HLS playback implementation and lower bitrate will be used instead to ensure smooth playback. | 0 |
loop | 0|1 | Indicates whether the media plays again after playback is complete. | 0 |
ssl | on|auto | Controls whether the video is delivered over secure SSL connection (HTTPS) or insecure (HTTP). When set to auto the video delivery protocol will be inherited from the protocol of embedding web page: if the web page is loaded over HTTPS, the video will be also delivered over HTTPS; and vice verse: if the web page is on HTTP, video will also be delivered over HTTP. When set to on , video delivery always happens over secure connection irrespective to the web page protocol. Applicable only for for Public video delivery in AEM. | auto |
waiticon | 0|1 | Enables or disables buffering animation (wait icon) display. | 1 |
video | file | file is an absolute or relative URL to the video content hosted outside of Scene7 or Dynamic Media, refer to component description for additional details. | "" |
preload | 0|1 | Indicates whether the component begins loading video content before the playback starts. If set to 1 the video begins to download right after the asset is set, otherwise preload starts only after the playback is initiated by the end user or an API call. When video preload is disabled certain features may not work until the playback starts, specifically seek operation will not update the video frame. Finally, disabling video preload may be ignored on certain versions of Internet Explorer 11 and Edge browsers. | 1 |
mutevolume | 0|1 | Sets muted mode for video playback on initial load. If set to 1 the volume is muted, otherwise video plays with sound. On certain devices muting video playback on load will also allow to auto play the video. | 0 |
posterimage | none | [IS_modifiers] | Image Serving modifiers which control poster image appearance. If specified in the URL the ? and all occurrences of & and = must be HTTP-encoded as %3F , %26 , and %3D , respectively. This modifier works for the video content hosted on Scene7 or Dynamic Media. To prevent displaying of the default poster image, specify none as the poster image value. | "" |
vrrender | true|false | Specifies if virtual reality rendering mode is enabled. Ignored on VR headsets. | false |
autorotate | 0|1 | When the modifier is "1" (or not specified and left by default), component's auto-rotation is used. In particular, autorotation should not happen if the autoplay is enabled. | 1 |
Defining the Appearance using CSS
You can define the appearance of the Video360Player
component using CSS rules. All HTML5 Viewer SDK components use class selectors for styling. You can style the body of the Video360Player
component by using
the .s7video360player
class selector. The styles that are associated with this class selector are applied to all instances of the Video360Player
component. You can style particular instances by prefixing
the class rule with the instance #id. For example, styling rules for #myComp.s7video360player
are applied only to the particular Video360Player
instance.
The styling of the sub-elements using class selectors like .s7iconeffect
for example, must be specified in the form of the descendant class selectors. That is,
they must follow the main class selector separated by a space, such as .s7video360player .s7iconeffect
.
For more information on component styling see the HTML5 Viewer SDK User Guide and the default styles section.
CSS Class | Attribute Selector | Description |
.s7video360player | (None) | Represents the main body of the Video360Player component. |
.s7iconeffect | state=[play|replay] | Defines the appearance of the IconEffect. If the video playback has reached the end component applies state=replay selector; otherwise state=play is used. |
.s7waiticon | (None) | Defines the appearance of wait icon when it is enabled. |
Localizable Symbols
Video360Player
also has s text symbol that you can localize either in a preset or in the viewer page though the mechanisms
provided by the ParameterManager
. For more information on localization consult the ParameterManager
API documentation and HTML5 Viewers SDK User Guide.
Symbol | Description |
Video360Player.ERROR | Defines a localized tooltip for the error message that appears when no video playback is possible. |
Video360Player.ROLE_DESCRIPTION | Define a localized "aria-roledescription" of Video360Player |
Video360Player.USAGE_HINT | Define a localized text for "aria-describedby" of Video360Player |
Video360Player.TRACK_DEVICE_ORIENTATION | Define a localized text for the button label which prompts the user to enable device orientation tracking on iOS systems of Video360Player |
Constructor Attributes | Constructor Name and Description |
---|---|
s7sdk.video.Video360Player(container, settings, compId)
|
Method Attributes | Method Name and Description |
---|---|
addEventListener(type, handler, useCapture)
Adds an event listener to the instance of the
Video360Player component. |
|
Pauses auto-rotate.
|
|
Resumes the auto-rotate if it is configured using
autorotate modifier but was paused with autoRotatePause()
call. |
|
dispose()
Dispose is used to remove itself and all sub-elements from the DOM
|
|
ended()
Returns true if the video playback has finished.
|
|
getAsset()
Returns the asset currently displayed in the viewer.
|
|
Returns a
VideoCapabilityState object that can be used to determine the
current state of the Video360Player component. |
|
Returns the current playback time, in milliseconds.
|
|
Returns the video duration in milliseconds or
undefined if duration is not currently available. |
|
Returns the current inner height of the component.
|
|
Returns the current amount loaded, in milliseconds.
|
|
getPov()
Returns the current point of view of the camera in virtual sphere.
|
|
Returns the current audio volume, from 0 (silent) to 1 (maximum).
|
|
getWidth()
Returns the current inner width of the component.
|
|
mute()
Mutes the audio volume.
|
|
muted()
Return the muted state.
|
|
pause()
Pauses playback.
|
|
play()
Starts playback.
|
|
resize(w, h)
Resizes the
Video360Player component to the specified width and height. |
|
seek(time)
Seeks to the specified time.
|
|
setAsset(assetName, posterImage)
Changes the current video.
|
|
setCSS(classname, property, value)
Sets a particular CSS class and property on a component
|
|
setItem(item)
Sets the current video displayed by the component.
|
|
setModifier(modObj)
Sets 1-N # of modifiers for the component.
|
|
setPov(pov)
Sets the point of view of the camera in virtual sphere.
|
|
setVideo(videoName, posterImage)
|
|
setVolume(volume)
Sets the current audio volume.
|
|
setVRRender(vrRender)
Set the value of vrRender, false for 360 mode, true for virtual reality mode
|
|
stop()
Stops playback.
|
|
Returns
true if the video supports inline playback in the current environment. |
|
Returns
true if programmatic volume control is supported in the current environment, false otherwise. |
|
Toggles between playback and pause.
|
|
unmute()
Restores the audio volume.
|
Example Code
This example demonstrates how to use the Video360Player component in a simple video viewer. In this example a Container object,
a Video360Player object, and a PlayPauseButton object are created. Every time a user clicks the button, the Video360Player playback
starts or pauses.
The code below does the following:
- The Scene7 HTML5 SDK is linked to the page and the required s7sdk components are included in the document head.
- A CSS Style is defined in the document head to control the appearance of the viewer.
- The s7sdk.Util.init() method is called to initialize the SDK.
- A ParameterManager object is created to handle component modifiers for the viewer.
- An initViewer() function is defined. This function initializes several modifiers (hard coded for example purposes),
then creates the component objects required for this simple example. The initViewer() function also adds event listeners
that designate functions to handle relevant component events (which might be dispatched by the components as a result of
user interactions, changes in a component's state, etc.).
- Handler functions are defined to respond to the component event listeners added in the initViewer() function.
- An event listener is added to the ParameterManager object that designates the initViewer() function as the handler
to call when the Scene7 SDK is loaded and ready.
- Finally, the init() method is called on the ParameterManager object to start the viewer.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- removed height=device-height, -->
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
<!-- Hiding the Safari on iPhone OS UI components -->
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="apple-touch-fullscreen" content="YES" />
<!-- Specifying a per-page Home screen icon -->
<link rel="apple-touch-icon" href=""/>
<link rel="apple-touch-startup-image" href="" />
<title>Video360Player Example</title>
<script language="javascript" type="text/javascript"
src="../js/s7sdk/utils/Utils.js"></script>
<script language="javascript" type="text/javascript">
s7sdk.Util.lib.include('s7sdk.common.Button');
s7sdk.Util.lib.include('s7sdk.common.Container');
s7sdk.Util.lib.include('s7sdk.event.Event');
s7sdk.Util.lib.include('s7sdk.video.Video360Player');
</script>
<style>
.s7video360player {
width:512px;
height:384px;
}
.s7videotoolbar {
display:block;
position: absolute;
top: 384px;
width: 512px;
height: 32px;
z-index: 5000;
padding: 0px;
background-color: #ccc;
}
</style>
</head>
<body>
<div id="s7toolbar" class="s7videotoolbar"></div>
<script language="JavaScript" type="text/javascript">
var params, container, video360Player, s7videotoolbar, playPauseButton;
// Initialize the SDK
s7sdk.Util.init();
// Create ParameterManager instance to handles modifiers
params = new s7sdk.ParameterManager();
// Define the function that initializes the viewer
function initViewer(){
// Set hardcoded modifiers (not required when values are specified on the url)
params.push("serverurl", "http://s7d1.scene7.com/is/image/");
params.push("videoserverurl", "http://s7d1.scene7.com/is/content/");
params.push("asset", "Viewers/space_station_360-AVS");
params.push("autoplay", "0");
// Create the Container component object
container = new s7sdk.Container(null, params, "s7container");
// Create Video360Player component object
video360Player = new s7sdk.video.Video360Player(container,params,"s7viewer");
// Create PlayPauseButton object
playPauseButton = new s7sdk.common.PlayPauseButton("s7toolbar", params, "playPauseBtn");
// Add an event listener for PlayPauseButton click events
playPauseButton.addEventListener("click", onClickPlayPause);
// Add an event listener for Video360Player capability change events
video360Player.addEventListener(s7sdk.event.CapabilityStateEvent.NOTF_VIDEO_CAPABILITY_STATE, onNotifyVideoState, false);
playPauseButton.setSelected(true);
}
// Define an event handler function to update the PlayPauseButton object when the Video360Player changes state
function onNotifyVideoState(event){
playPauseButton.setSelected(event.s7event.state.hasCapability(s7sdk.VideoCapabilityState.PLAY));
}
// Define an event handler function to update the Video360Player object when the PlayPauseButton is clicked
function onClickPlayPause(event){
if(!playPauseButton.isSelected()){
video360Player.play();
}else{
video360Player.pause();
}
}
// The ParameterManager will dispatch SDK_READY when all modifiers have been processed
// and it is safe to initialize the viewer
params.addEventListener(s7sdk.Event.SDK_READY, initViewer, false);
// Now it is safe to process the modifiers, the callbacks have been defined
// this will trigger the SDK_READY event
params.init();
</script>
</body>
</html>
Default styles for Video360Player:
.s7video360player {
cursor: pointer;
position:absolute;
background-color:#000000;
-webkit-touch-callout:none;
-webkit-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
user-select:none;
-webkit-tap-highlight-color:rgba(0,0,0,0);
}
.s7video360player .s7iconeffect {
width:120px;
height:120px;
-webkit-transform:translateZ(0px);
background-repeat:no-repeat;
background-position:center;
}
.s7video360player .s7iconeffect[state='play'] {
background-image:url(images/sdk/video360playicon.png);
}
.s7video360player .s7iconeffect[state='replay'] {
background-image:url(images/sdk/videoreplayicon.png);
}
.s7video360player .s7waiticon {
background-image:url(images/sdk/busyicon.gif);
background-repeat:no-repeat;
background-position:center;
position:absolute;
width:101px;
height:29px;
left:50%;
top:50%;
margin-left:-50px;
margin-top:-15px;
}
.s7container .s7trackdeviceorientationbutton {
position : 'absolute';
bottom : '90px';
padding : '12px 6px';
border : '1px solid #fff';
background : 'rgba(0,0,0,0.1)';
color : '#fff';
font : 'normal 13px sans-serif';
textAlign : 'center';
outline : 'none';
zIndex : '999';
cursor : 'pointer';
left : 'calc(50% - 100px)';
width : '200px';
}
- Parameters:
- {String|Container} container
- The reference to
Container
instance or the ID of the parent DOM element to which the component is added as a child - {s7sdk.ParameterManager} settings
- A parameter manager instance that represents the desired configuration.
- {String} compId
- An optional parameter that specifies the ID of the component DOM element.
Video360Player
component. The handler function
receives a DOM event object of type Event
. The object contains a property s7event
,
which references the associated custom event object, for example s7sdk.event.VideoEvent
.
The events supported by the component are:
s7sdk.event.VideoEvent.NOTF_CURRENT_TIME
- Dispatched to report the current playback time. s7sdk.event.VideoEvents7sdk.event.UserEvent.CURRENT_TIME
- The event is dispatched each time the video time is changed to report the current playback time. s7sdk.event.UserEvents7sdk.event.VideoEvent.NOTF_DURATION
- Dispatched to report the video duration, when read from the asset. s7sdk.event.VideoEvents7sdk.event.VideoEvent.NOTF_LOAD_PROGRESS
- Dispatched to report the current amount of the video that has loaded. s7sdk.event.VideoEvents7sdk.event.VideoEvent.NOTF_VOLUME
- Dispatched when playback volume has changed. s7sdk.event.VideoEvents7sdk.event.VideoEvent.NOTF_SEEK
- Dispatched to report when a seek is performed. s7sdk.event.VideoEvents7sdk.event.VideoEvent.NOTF_VIDEO_END
- Dispatched to report when playback of the current vide has ended. If loop
modifier set in 1
playback never stops and this event never fires. s7sdk.event.VideoEvents7sdk.event.CapabilityStateEvent.NOTF_VIDEO_CAPABILITY_STATE
- Dispatched when the play, pause, mute, unmute or stop capabilities have changed. s7sdk.event.CapabilityStateEvents7sdk.event.AssetEvent.ASSET_CHANGED
- Dispatched when the currently played video changes. s7sdk.event.AssetEvents7sdk.event.StatusEvent.NOTF_ASSET_METADATA_READY
- Dispatched when component receives asset metadata. If the component is initialized with setItem()
it dispatches instantly inside that API call. Otherwise if the component loads req=set on its own, this event is sent when component has received and parsed req=set. s7sdk.event.StatusEvents7sdk.event.StatusEvent.NOTF_VIEW_READY
- Dispatched when component fills the view entirely with image data. It is sent only after asset swap. s7sdk.event.StatusEvents7sdk.event.PovEvent.NOTF_POV_CHANGE
- Dispatched when component when a POV (PointOfView) changes because of auto rotation, end user interaction or setPov()
API call. s7sdk.event.PovEvent- Parameters:
- {String} type
- Event name, for example
s7sdk.event.VideoEvent.NOTF_CURRENT_TIME
. - {Function} handler
- Function to be called when the event gets dispatched.
- {Boolean} useCapture
- Register capture phase.
autorotate
modifier but was paused with autoRotatePause()
call. This method has no effect if auto-rotate was not enabled in the component settings.
- Returns:
- whether video playback has finished.
- Returns:
- current video asset
VideoCapabilityState
object that can be used to determine the
current state of the Video360Player
component. For example, if the video player has the
PAUSE
capability flag set, then this indicates that the video can be paused.
- Returns:
- the current capabilities of the
Video360Player
instance.
- Returns:
- current playback time
undefined
if duration is not currently available.
- Returns:
- video duration
- Returns:
- {Number} the inner height of the component, in pixels.
- Returns:
- amount of loaded video data
- Returns:
- {s7sdk.PovDesc} current point of view.
supportsVolumeControl()
), returns 1.
- Returns:
- current volume
- Returns:
- {Number} the inner width of the component, in pixels.
supportsVolumeControl()
).
supportsVolumeControl()
), returns false.
- Returns:
- {Boolean} True if in muted state, false otherwise
Video360Player
component to the specified width and height.
- Parameters:
- {Number} w
- The width of the component, in pixels.
- {Number} h
- The height of the component, in pixels. .
- Parameters:
- {float} time
- the time to seek to in the video, in milliseconds
SWAP
tracking event that is managed by the TrackingManager
component. Preferred way of changing the current video though is by simply calling
setItem()
API.
- Parameters:
- {String} assetName
- the asset id of the single video or Adaptive Video Set.
- {String} posterImage
- (optional) the IS_modifiers for the poster image to be used.
- Parameters:
- {String} classname
- The CSS classname to use for this style. i.e. .s7video360player
- {String} property
- The CSS property that is being set. i.e. background-color
- {String} value
- The CSS property value being set. i.e. #FF0000
VideoDesc
or MediaSetDesc
. An
exception is thrown if the item does not reference a parent set, or is not of type VideoDesc
or MediaSetDesc
. Calling this
method will dispatch the AssetEvent.ASSET_CHANGED
event.
- Parameters:
- item
- {s7sdk.VideoDesc} The video item to display.
- Parameters:
- {Object} modObj
- A simple JSON object with name:value pairs of valid modifiers for a particular component
- Parameters:
- {s7sdk.PovDesc} pov
- current point of view.
- Parameters:
- {String} videoName
- an absolute or relative URL to the video content hosted outside of Scene7 or Dynamic Media.
- posterImage
supportsVolumeControl()
).
- Parameters:
- volume
- {float} new volume, from 0 (silent) to 1 (maximum).
- Parameters:
- vrRender
- True to enable virtual reality mode, default to false
true
if the video supports inline playback in the current environment. Some platforms, like iPhone prior to iOS 10 and Android prior to 4.0, do not support inline playback.
- Returns:
- whether the device can support inline video playback
true
if programmatic volume control is supported in the current environment, false
otherwise. Some platforms like iPhone, iPad and Android do not support volume control using JavaScript.
- Returns:
- whether it is possible to control playback volume with JavaScript
supportsVolumeControl()
).