Properties

Read the player state at any moment

Properties are read-only. Like the methods, they need the player to be initialized — before player:ready or iframe:connected they return defaults rather than real values.

Player states groups these by the question they answer, which is usually the more useful way in.

Prop

Type

alreadyPlayed

Whether the video has played at all in this session. It stays true after a pause — see paused for the momentary state.

const player = document.querySelector("vturb-smartplayer");

player.addEventListener("player:ready", () => {
  console.log(player.alreadyPlayed);
});

conversionKey

Identifies the current view: the session, the player and variant, how much has been watched, and which feature variants are active.

Returns an empty string until the player is ready. Reading it too early is the usual reason it arrives empty at a checkout.

const player = document.querySelector("vturb-smartplayer");

player.addEventListener("player:ready", () => {
  console.log(player.conversionKey);
});

currentSpeed

Current playback rate, where 1 is normal speed. It follows every change of rate, including the viewer's choice in the speed menu and calls to speed.

const player = document.querySelector("vturb-smartplayer");

player.addEventListener("player:ready", () => {
  console.log(player.currentSpeed);
});

currentTime

Playback position, in seconds.

const player = document.querySelector("vturb-smartplayer");

player.addEventListener("player:ready", () => {
  console.log(player.currentTime);
});

duration

Video length, in seconds.

Available only once the video has loaded. It returns 0 before that, which is not the same as a zero-length video.

const player = document.querySelector("vturb-smartplayer");

player.addEventListener("player:ready", () => {
  console.log(player.duration);
});

inResume

Whether the player is offering to resume from where the viewer stopped previously.

const player = document.querySelector("vturb-smartplayer");

player.addEventListener("player:ready", () => {
  console.log(player.inResume);
});

inSmartAutoPlay

Whether the video is in the muted SmartAutoPlay state, meaning it started without audio and has not yet played with it.

const player = document.querySelector("vturb-smartplayer");

player.addEventListener("player:ready", () => {
  console.log(player.inSmartAutoPlay);
});

paused

Whether playback is paused right now.

const player = document.querySelector("vturb-smartplayer");

player.addEventListener("player:ready", () => {
  console.log(player.paused);
});

played

Whether playback has been started, by the viewer, by play() or by unmuting SmartAutoPlay. The muted SmartAutoPlay preview does not count.

const player = document.querySelector("vturb-smartplayer");

player.addEventListener("player:ready", () => {
  console.log(player.played);
});

volume

Current volume, between 0.0 and 1.0.

const player = document.querySelector("vturb-smartplayer");

player.addEventListener("player:ready", () => {
  console.log(player.volume);
});

On this page