Player initialization parameters
You can provide initial parameters to Cloud Video Player when initializing it.
element
Embed element. This is a required parameter. This can be either a pointer to a certain HTMLElement
or an ID selector.
Player creation examples:
-
By providing a pointer:
var element = document.getElementById('video-player'); var player = Ya.playerSdk.init({ element, ...});
-
By providing an ID selector:
var player = Ya.playerSdk.init({ element: 'video-player', ...});
source
Playable content link.
Player creation examples:
var player = Ya.playerSdk.init({ ..., source: 'https://runtime.video.cloud.yandex.net/player/...', ...});
Where https://runtime.video.cloud.yandex.net/player/...
is a link to playable content, e.g., https://runtime.video.cloud.yandex.net/player/video/vplvmyqsxi7dlwndvb4y
. For more information, see Getting an embed code or link to a video and Getting an embed code or link to a broadcast.
autoplay
Autoplay when loading content.
In some cases, autoplay may fail
Autoplay is disabled by default.
Player creation examples with disabled autoplay:
var player = Ya.playerSdk.init({ ..., autoplay: false, ...});
muted
muted
status when creating a player. true
to disable sound, false
to enable sound.
If the sound is on, autoplay may fail
Player creation examples with enabled sound:
var player = Ya.playerSdk.init({ ..., muted: false, ...});
volume
Volume level of a video from 0
(muted) to 1
(maximum volume).
The default value is 1
.
Player creation example with the 0.5
volume:
var player = Ya.playerSdk.init({ ..., volume: 0.5, ...});
startPosition
Starting position of content playback when loading (in seconds).
The default values are:
- For the
VOD
video type: Beginning of the video (zero second). - For the
LIVE
andEVENT
video types: Live.
Player creation example with the 10
starting position:
var player = Ya.playerSdk.init({ ..., startPosition: 10, ...});
hiddenControls
Using hiddenControls
, you can hide the player interface elements.
All the controls are shown by default.
As a value, you can provide either an array of interface elements to hide or a string listing such elements separated by commas.
Examples:
-
Hide the play/pause and settings buttons by providing
hiddenControls
as a string:var player = Ya.playerSdk.init({ ..., hiddenControls: 'play,settings', ...});
-
Hide the play/pause and settings buttons by providing
hiddenControls
as an array:var player = Ya.playerSdk.init({ ..., hiddenControls: ['play','settings'], ...});
-
You can hide all interface elements using the
*
meta element:var player = Ya.playerSdk.init({ ..., hiddenControls: '*', ...});
-
You can hide all interface elements except a specific one using the
!
operator. For example, the following code will hide all controls except the play/pause button:var player = Ya.playerSdk.init({ ..., hiddenControls: '*,!play', ...});
Interface elements you can hide:
*
: All interface elements.play
: Interface element displaying the Play, Pause, and Repeat buttons. It turns off play or pause when clicking the player.contextMenu
: Context menu.fullscreen
: Full screen toggle button.live
: Go back to live button.mobileSeekButtons
: Rewind and fast forward buttons in the mobile interface.nextAdInfo
: Time until the next ad.playbackRate
: Playback rate.poster
: Poster.preloader
: Loading spinner.settings
: Settings button.startScreen
: Start screen.startScreenPlay
: Play button on the start screen.subtitlesToggle
: Button to toggle subtitles.timeline
: Timeline. It turns off rewinding and fast forwarding from the keyboard or by touching the sensor screen.timelinePreview
: Preview on the timeline.time
: Current playback time.title
: Video title.sound
: Mute button.volumeSlider
: Volume slider.
See also
- Interface: PlayerSdkInitConfig API reference
- Interface: PlayerSdkSourceParams API reference