All Collections
Vidalytics Code Customizations
Forcing a Specific Speed in Your Video
Forcing a Specific Speed in Your Video
Erika Lehmann avatar
Written by Erika Lehmann
Updated over a week ago

You can force a specific speed on your video other than the normal one using our API. However, keep in mind that the text on the Playback Speed button (1X, 1.5X, 2X, etc.) in the Control Bar wouldn't be automatically changed, so it might be confusing for your viewers.

If you'd still like to proceed with this, here's the script you'd need to use:

<script>
var EMBED_CODE_ID = 'vidalytics_embed_EMBED_CODE_HERE'; // update this to match your Vidalytics Embed ID
var vidalyticsPlayerAPI = null;

function initializePlayerAPI() {
var player = getPlayer();
if (player._player) {
vidalyticsPlayerAPI = player;
onPlayerAPIAvailableCallback();
return;
}

setTimeout(initializePlayerAPI, 100);
}
initializePlayerAPI();

function getPlayer() {
var embeds = (window._vidalytics || {}).embeds || {};
if (embeds[EMBED_CODE_ID]) {
return embeds[EMBED_CODE_ID].player || {};
}
return {};
}

function onPlayerAPIAvailableCallback() {
// values can be 0.5, 0.75, 1, 1.25, 1.50, 2, etc.
vidalyticsPlayerAPI._player.player.setPlaybackSpeed(5); // x5
}
</script>

As always, make sure to replace EMBED_CODE_HERE with your actual embed code ID πŸ˜‰

Did this answer your question?