Skip to main content
The shell plays the video in its own player: AVPlayer on iOS, ExoPlayer on Android, the shell’s player on desktop, and a remote-controlled player on TV. Your page passes a URL and gets back playback state. The platform provides the controls, including scrubbing, picture-in-picture, full screen and casting to a TV. When the player closes, play resolves with the position where the viewer stopped.

Options

string
required
An http(s) URL: a progressive file (mp4, webm) or an HLS / DASH manifest.
'mp4' | 'webm' | 'hls' | 'dash'
Stream format. If you leave it out, the SDK infers it from the URL: .m3u8 is hls, .mpd is dash, .webm is webm, and anything else is mp4. Set it when a manifest’s URL doesn’t end in the usual extension.
string
Shown above the video.
string
Second line, such as a channel or show name.
string
Image shown until the first frame arrives.
number
Position to start from, in seconds. Ignored for live.
boolean
default:"true"
Start playing as soon as the video is ready.
boolean
default:"false"
Start again from the beginning when the video ends.
boolean
default:"false"
Start with the sound off.
boolean
default:"false"
A live stream. The player hides seeking and shows a LIVE badge.
boolean
default:"false"
Close the player when the video ends. Without it, the player stays open on the last frame. Ignored with loop.
boolean
default:"true"
Let the viewer send the video to a TV with AirPlay or Chromecast. Set it to false for content you aren’t allowed to show on a second screen.
number
default:"0"
While playing, send a progress event every this many seconds. With 0, no progress events are sent. The final position always comes with the result.
string
Returned on every event and on the result.

Events

The optional second argument of play (or openPlayer) receives every state change while the player is open:
'ready' | 'play' | 'pause' | 'buffering' | 'progress' | 'ended' | 'error' | 'cast'
What happened. cast means playback moved to a TV or came back to the device.
number
Current position, in seconds.
number
Length in seconds. It is 0 until the length is known, and stays 0 for a live stream.
'airplay' | 'chromecast' | null
On cast events only. Where the video plays now, or null when it’s back on the device.
string
On cast events only. The TV’s name, when the shell knows it. Only Chromecast reports it.
While the video plays on a TV, the other events describe the TV’s playback. The progress events and the final position keep working, so you can save resume points the same way.

Result

number
Where playback stopped, in seconds. Save it and pass it back as startAt to resume.
number
Length of the video in seconds.
boolean
Playback reached the end at least once.
'not_available' | 'busy' | 'invalid_source' | 'playback_failed'
not_available: this surface has no player. busy: another video is already open. invalid_source: the URL is not http(s), or this platform can’t play the format. playback_failed: the stream couldn’t be loaded.

Supported formats

Check availability.formats, or call getPlayerAvailability(), before you choose which URL to pass. The player doesn’t support DRM or custom request headers. To protect a stream, use a signed URL that carries its token in the query string.

Casting to a TV

On iOS the viewer can send the video to a TV with AirPlay. On Android a Cast button appears next to the title when a Chromecast is on the same network. The video continues on the TV from the same position, and the phone shows a remote with play, pause and seek. When the viewer stops casting, playback continues on the phone from where the TV left off. availability.cast lists where the current shell can cast: ['airplay'] on iOS, ['chromecast'] on Android, and [] everywhere else. The TV downloads the video itself, not through the phone. Make sure that:
  • The URL works from the TV. A signed URL must stay valid until the viewer is likely to finish watching.
  • For HLS and DASH on Chromecast, your server sends an Access-Control-Allow-Origin header on the manifest and its segments.
Only one video can be open at a time. To close it from your page, call close() (or closePlayer()). Without the hook, use openPlayer(options, onEvent?), closePlayer() and getPlayerAvailability(). isPlayerAvailable() is a shortcut that resolves only the available flag, and inferPlayerFormat(src) returns the format openPlayer would report for a URL.