Player basics¶
Once your player is up and running, most integrations need two more things: a simple playback UI and a few basic playback options. This page walks through both.
Code samples
Simple UI: a container around the video, a poster shown before playback starts, and a big play button.
Player configuration: sets the start time, volume, and muted state from a form.
React integration: a React player component with play/pause, a seek bar, and fullscreen.
Simple UI example¶
The Simple UI sample shows a
minimal playback UI: a container around the video element, a poster image
shown until playback starts, and a big play button. The container is passed to
the player as containerEl, so the poster and the button can sit on top of
the video.
Playback and basic configuration¶
The player accepts a PlayerConfiguration object in its
constructor, and a source in the Player.open call. Here are the
options you’ll reach for first.
Loading content¶
Pass a configuration object with a source property:
player.open({
source: 'https://example.com/manifest.mpd',
});
source also accepts an array of URLs. The player tries them in order and
plays the first one it can play on the current platform:
player.open({
source: [
'https://example.com/manifest1.mpd',
'https://example.com/manifest2.mpd',
'https://example.com/master.m3u8',
],
});
Supported formats¶
Supported types are clpp.Type.DASH, clpp.Type.HLS,
clpp.Type.SMOOTH_STREAMING, and clpp.Type.MP4. If the format can’t be
deduced from the file extension, specify it explicitly as type:
player.open({
source: 'https://example.com/manifest.foo',
type: clpp.Type.DASH,
});
Start time, volume, and muted state¶
player.open({
source: 'https://example.com/manifest.mpd',
startTime: 300, // start 5 minutes in, VOD only
volume: 0.5,
autoplay: true,
muted: true,
});
For live content, the player starts at the live edge by default.
See Tracks and languages for setting the initial audio and text language.
React integration¶
Building your app with React? The React integration sample wraps PRESTOplay for Web Apps in a function component, from creating and destroying the player to a seek bar that also works with live content.
The React integration sample covers:
Creating the player on mount and destroying it on unmount
Loading content when a prop changes
A play/pause button driven by
clpp.events.STATE_CHANGEDFullscreen on the component’s container element
A seek bar based on
Player.getSeekRange, which also supports live content