PlayKit Basics for OVP Apps
On this page:
- Player interface
- Events
- States
- PlayKit Manager
- Plugins
- Data objects
- Sample code
- Locations
- Additional topics
Player interface
- Android: Player.java (com.kaltura.playkit.Player)
- iOS: Player.swift and BasicPlayer.swift
The methods/properties names sometimes differ between iOS and Android due to platform naming conventions.
Methods
- prepare(): takes a PKMediaEntry objects and make it ready for playback
- play(): start playing the prepared media. If called before the media is ready to play, playback will start when ready.
- pause(): temporarily pause playback
- stop(): stop playback (release resources of current media)
- seek(): seek to a position
- destroy(): release all player resources
- addObserver()/addListener(): add listener to the player’s events.
Properties
- duration
- currentTime/position
- isPlaying
- isLive
- rate
Events
The player sends events to the application. The primary events are:
- canPlay: the player has loaded the media and is ready to play
- durationChanged: the media’s duration is known or has changed
- ended: playback of current media is complete
- play: play was requested
- playing: playback has started
- pause: pause was requested
- seeking: the player started seeking
- seeked: seeking has finished
- stateChanged: the player state has changed
States
At all times the player is in a given state:
- idle: no media loaded (yet)
- ready: ready to play
- buffering: not playing because media is loading
- ended: media playback is complete
PlayKit Manager
Static/singleton class used to load a new Player instance.
Methods
- loadPlayer(): create a new player instance
- registerPlugin(): register a player plugin
Plugins
PlayKit has a built-in plugin system. All plugins implement a PKPlugin interface. The application is responsible for registering them (once, before starting the player for the first time) and setting/updating their configuration.
Kava plugin
Kava is Kaltura’s Advanced Video Analytics service. We provide this plugin with sample code.
There are other analytics plugins, as well as a plugin for displaying video ads.
Data objects
PKMediaEntry holds the information of a specific entry with all of its available sources, ready to be sent to the player. It contains a list of PKMediaSource objects.
PKMediaSource holds the URL and optionally other information required for playback.
Sample code
OVP Starter shows how to use the built-in OVP media providers to load media info from Kaltura API, load a player with Kava plugin, and connect a basic UI.
Android | iOS |
Locations
See Components.
Additional topics
Topic | Android | iOS |
---|---|---|
Casting | Guide :: Sample | Guide :: Sample |
Track Selection | Guide :: Sample | Guide :: Sample |
Error Handling | Sample | Guide |