Requests and commands


To control the player and requests via Javascript, use the apioperator
var player = new Playerjs({...});
console.log(player.api("id"));
player.api("play");
For some commands you can specify a parameter
player.api("play","URL");

Command Parameter Action Return
play - starting playback* -
play URL, playlist or id: starting playback of new source* false or true for id:
pause - pause playback -
toggle - toggle playback -
stop - stop playback -
mute - mute sound -
unmute - unmute sound -
seek time in seconds seek (after starting) -
fullscreen - go to full screen mode** -
exitfullscreen - exit from full screen mode -
isfullscreen - - true or false
playing - - true or false
started - - true or false
time - - current time of playback
duration - - duration in seconds
muted - - true or false
volume nothing or volume level the command returns the volume level or sets the value (from 0 to 1)
volume level (from 0 to 1)
quality - - current quality
audiotrack - - current audiotrack
id - - id of the player container
log - - debug log
screenshot - takes a screenshot false or base64
subtitle URL launching subtitle from the source -
poster URL displays the poster if the player is paused true or false
title text or nothing displays the title if there is such element enabled player.api("title","text"), or return current value  player.api("title") true or title value
playlist object [ ] or url updates playlist  true or false
playlist_id - return id of the played track from playlist id
playlist_title - return title of the played track from playlist title
find file id open track from playlist by id and wait of the starting true or false
scale transformation step, or format changes the video scale (floating-point number) or aspect ratio for incorrectly encoded video (width:height, for example 4:3 or 16:9)
-
showplaylist - show playlist -
visibility - - precent of the player visibility
hlserror
dasherror
- - object error for HLS / DASH
hls
dash
- - object hls.js or dash.js (direct access to the plugin)
* you can add the option seek player.api("play","url[seek:10]"); to start with the desired second. First launching on mobile with sound works only after the user gestures.

** on all platforms only due to user actions

The API is in a constant development process, if you have something missing - write to us via feedback.

How to get the players events

You can read about listening to player events here.

How to send commands to the player inside the iframe

There is a special way for this postMessage. To make it work, you need to enable in the settings. Plugins / API / postMessage for iframe. For example, iframe looks like this:

<iframe id="player" src="https://site.com/video.html" type="text/html" width="640" height="360" frameborder="0" allowfullscreen=""></iframe>

To send him a command you need to pass an object with the command api

document.getElementById("player").contentWindow.postMessage({"api":"play"}, "*");

If you need to pass a parameter, then  set is added to the object.

document.getElementById("player").contentWindow.postMessage({"api":"volume","set":0.5}, "*");

* at the end means that you trust this iframe. If not, then you need to pass URI.




2018 © PlayerJS

Login

Restore password
Sign up
Log in

Sign up free

Sign up
By signing up, you agree to Terms of Service
Login if you have an account

Enterprise

Your name
Website
Email
Phone
Description
Order player

Restore password

Restore
Forgot email? Contact us