---
title: "Video Player API: Control the Kinescope Player with JavaScript | Kinescope"
description: "Kinescope IFrame Player API: 33 methods and events for play, seek, quality, subtitles, fullscreen and playlists. Install the loader, create the player, try it live."
url: https://kinescope.com/developers/player-api
---

# Video player API for JavaScript

Control the Kinescope player embedded on your page: play, seek, change speed and quality, switch subtitles and playlists, and react to what the viewer does.

[Start for free](https://app.kinescope.io/user/create?lang=en)[View on GitHub](https://github.com/kinescope/player-iframe-api-loader)

## Control the player from your code

A real Kinescope player. Each button calls an IFrame Player API method, the panel shows the code that ran, and the log shows the events the player sends back.

Live player Loads as you scroll here

currentTime

0

paused

true

playbackRate

1

quality

—

volume

1

muted

false

Playback

Seek result Try `seekTo(90)` to jump to 1:30.

Speed

Quality

Sound

Subtitles

Watermark

```
// Try seekTo(90) in the live player
```

Events

1.  Events appear here once the player loads.

player.js

```
import { load } from '@kinescope/player-iframe-api-loader';

const factory = await load();
const player = await factory.create('player', {
  url: 'https://kinescope.io/56Jg27MqvvttAwHcrCzEA4',
  size: { width: '100%', height: '100%' },
});

player.on(player.Events.TimeUpdate, ({ data }) => {
  console.log(data.currentTime, data.percent);
});
```

Every method and event is in the [IFrame Player API docs](https://docs.kinescope.com/player-docs/embedding/iframe-api/).

## Quick start

Install @kinescope/player-iframe-api-loader and control your first video. Code from the package README and the API types.

Install the loader

The loader fetches the IFrame API and ships TypeScript types for every method and event.

Create the player

Pass an element or its ID and the video link. `size` and `behavior` are optional.

Call methods and listen to events

Every method returns a Promise. Subscribe with `on`, `once` and `off`.



terminal

```
npm install @kinescope/player-iframe-api-loader
```



player.ts

```
import * as iframeApiLoader from '@kinescope/player-iframe-api-loader';

const factory = await iframeApiLoader.load();
const player = await factory.create('player', {
  url: 'https://kinescope.io/VIDEO_ID',
  size: { width: '100%', height: 400 },
});
```



player.ts

```
player.on(player.Events.Ended, () => {
  console.log('Lesson finished');
});

await player.seekTo(90);
await player.setPlaybackRate(1.5);
await player.play();
```

Install the loader

The loader fetches the IFrame API and ships TypeScript types for every method and event.



terminal

```
npm install @kinescope/player-iframe-api-loader
```

Create the player

Pass an element or its ID and the video link. `size` and `behavior` are optional.



player.ts

```
import * as iframeApiLoader from '@kinescope/player-iframe-api-loader';

const factory = await iframeApiLoader.load();
const player = await factory.create('player', {
  url: 'https://kinescope.io/VIDEO_ID',
  size: { width: '100%', height: 400 },
});
```

Call methods and listen to events

Every method returns a Promise. Subscribe with `on`, `once` and `off`.



player.ts

```
player.on(player.Events.Ended, () => {
  console.log('Lesson finished');
});

await player.seekTo(90);
await player.setPlaybackRate(1.5);
await player.play();
```

## Methods you’ll use most

Every method returns a Promise. [All 33 methods in the API docs](https://docs.kinescope.com/player-docs/embedding/iframe-api-control-player/).

-   ### `play() · pause()`Promise

    Start or pause playback.

-   ### `seekTo(time)`Promise

    Jump to a second, for example to resume a lesson.

-   ### `getCurrentTime()`Promise<number>

    Where the viewer is now, in seconds.

-   ### `getDuration()`Promise<number>

    Length of the video, in seconds.

-   ### `setPlaybackRate(value)`Promise

    Change speed, for example 1.5.

-   ### `setVideoQuality(q)`Promise

    Fix a quality, such as 720p.

-   ### `enableTextTrack(lang)`Promise

    Turn on subtitles in a language.

-   ### `setFullscreen(on)`Promise

    Enter or leave fullscreen.

-   ### `switchTo(id) · next()`Promise

    Change the video in a playlist.

-   ### `setOptions(options)`Promise

    Change player options on the fly, such as the watermark.


## Events

-   ### `Loaded`Call methods safely after it.

    The player and video are ready.

-   ### `Play · Pause`Sync your own buttons.

    The viewer starts or pauses.

-   ### `TimeUpdate`Save lesson progress.

    Playback position changes.

-   ### `Ended`Mark a lesson as watched, open the next one.

    The video reaches the end.

-   ### `QualityChanged`Log what viewers actually get.

    The quality switches.

-   ### `CallAction`Count clicks or open a form.

    A viewer clicks a call to action.

-   ### `Error`Show your own message or report it.

    Playback fails.

-   ### `player.on(Events.Ended, fn)`Also once and off.

    Subscribe to any event.


## Documentation and code

DocumentationCodeTools

-   ### Documentation

    [IFrame Player API](https://docs.kinescope.com/player-docs/embedding/iframe-api/)[Control the player](https://docs.kinescope.com/player-docs/embedding/iframe-api-control-player/)[Simple iframe embed](https://docs.kinescope.com/player-docs/embedding/simple-iframe-embed/)


-   ### Code

    [@kinescope/player-iframe-api-loader on GitHub](https://github.com/kinescope/player-iframe-api-loader)[JavaScript video player](https://kinescope.com/developers/javascript-video-player)[React player component](https://kinescope.com/developers/react-video-player)[Next.js video player](https://kinescope.com/developers/nextjs-video-player)[Vue player component](https://kinescope.com/developers/vue-video-player)


-   ### Tools

    [Embed code generator](https://kinescope.com/tools/embed-code-generator)[Video bitrate calculator](https://kinescope.com/tools/video-bitrate-calculator)


## FAQ

Can’t find the answer you need? Check out our [Player docs](https://docs.kinescope.com/player-docs/embedding/iframe-api/).

A JavaScript API for a video player embedded in an iframe: your page calls methods such as play, seek or change quality, and the player sends back events such as playing, paused or ended. It is how you build custom controls, lesson progress tracking or interactive video on top of an embedded player.

Install `@kinescope/player-iframe-api-loader`, call `load()` to get the player factory, create the player with `factory.create(element, { url })`, then call its methods and subscribe to events with `player.on(player.Events.Ended, handler)`. The quick start on this page has the code.

Yes. Listen to `Ended` for the end of the video and to `TimeUpdate` for the current position, then save progress on your backend. `getCurrentTime()` and `getDuration()` return the values on demand.

No. The loader replaces the `onKinescopeIframeAPIReady` callback and adds TypeScript types. If the IFrame API script is already on the page, use `window.Kinescope.IframePlayer` directly; the types are available on their own from `@kinescope/player-iframe-api-loader/types`.
