weex-kdp
Kaltura Dynamic Player implementation as Weex Components
Installing the plugin in your project
weexpack
:
Using weex plugin add weex-kdp
Manual integration:
iOS:
pod 'WeexKdp'
Android:
Add the following line to the dependencies list in the build.gradle file for the corresponding project.
compile '${groupId}:weexkdp:{$version}'
Note: You need to specify the groupId and $version of the project.
Web integration
npm install weexkdp
API
Template
<weex-kdp>
Adds the weex-kdp
plugin to the template. See Data: MediaEntry.
Calling methods
Use the sendNotification method to create custom notifications that instruct the player to perform an action, such as play, seek, or pause.
Example:
this$refskdp;
Available Notifications
changeMediaEntry
(ios)
Prepare for playing an entry. Play when it’s ready.
- (JSON)
MediaEntry
: see Data: MediaEntry.
this$refskdp;
doPlay
(iOS)
Plays the video.
this$refskdp
doPause
(iOS)
Pauses the video.
this$refskdp
doSeek
(iOS)
Sets the play time of the video.
- (float) time.
this$refskdp
changeVolume
(NOT IMPLEMENTED)
Changes the volume. The volume is a value between 0 and 1.
- (float) volume.
this$refskdp
selectTrack
(NOT IMPLEMENTED)
Selects a track by trackId
. See tracksAvailable(callback).
- (string) trackId.
this$refskdp
Getting player properties
Use the getProperty method to retrieve data from the plugin, such as duration
, time
, state
, audioTrack
, textTrack
,
duration
(iOS)
Returns the duration of the video.
callback
:fn(duration)
callback returning the duration of the video.- (float)
duration
- (float)
this$refskdp
time
(iOS)
Returns the current play time of the video.
callback
:fn(duration)
callback returning the plat time of the video.- (float)
time
: play time of the video
- (float)
this$refskdp
state
(NOT IMPLEMENTED)
Returns the current state of the video.
callback
:fn(duration)
callback returning the state of the video.- (string)
state
: the state of the video (idle
,loading
,ready
,buffering
,error
)
- (string)
this$refskdp
textTrack
(NOT IMPLEMENTED)
Returns the current text trackId. See tracksAvailable(callback).
callback
:fn(trackId)
- (string)
trackId
- (string)
this$refskdp
audioTrack
(NOT IMPLEMENTED)
Returns the current audio trackId. See tracksAvailable(callback).
callback
:fn(trackId)
- (string)
trackId
- (string)
this$refskdp
Listening to Events
Register player events with kBind
and unregister events with kUnbind
.
kBind(eventName, callback)
Registers an event.
eventName
: name of the event (See Event List).callback
:fn(eventData)
callback of the event.
this$refskdp;
kUnbind(eventName)
Unregister an event.
eventName
: name of the event (See Event List).
this$refskdp;
Event List
timeChange
(iOS)
Updates the callback each 500ms with the current time of the video.
callback
:fn(currentTime)
callback returning the current time of the video.- (float)
currentTime
- (float)
this$refskdp
stateChange
(iOS)
Dispatched when media player's state has changed.
callback
:fn(playerState)
- (string)
playerState
: MediaPlayerState:uninitialized
/loading
/ready
/playing
/paused
/buffering
/playbackError
- (string)
this$refskdp
durationChanged
(NOT IMPLEMENTED)
Sent when enough data is available that the media can be played, at least for a couple of frames.
callback
:fn()
this$refskdp
ended
(NOT IMPLEMENTED)
Sent when playback completes.
callback
:fn()
this$refskdp
loadedMetadata
(NOT IMPLEMENTED)
The media’s metadata has finished loading; all attributes now contain as much useful information as they’re going to.
callback
:fn(metadata)
- (object)
metadata
- (object)
this$refskdp
seeking
(NOT IMPLEMENTED)
Sent when a seek operation begins.
callback
:fn()
this$refskdp
seeked
(NOT IMPLEMENTED)
Sent when a seek operation completes.
callback
:fn()
this$refskdp
tracksAvailable
(NOT IMPLEMENTED)
Sent when tracks available.
callback
:fn(tracks)
- (JSON)
tracks
: JSON with the available tracks in the format:
audioTracks:id: "id"title: "title"language: "language"...textTracks:id: "id"title: "title"language: "language"...- (JSON)
this$refskdp
Data
MediaEntry
Description of the player configuration. Used in prepare
and prepareNext
.
A media entry can have multiple sources that would be the same video in different formats. The player will choose the source more appropriate to the device.
id: 'entryId' sources: contentUrl: 'url' mediaFormat: 'mediaFormat' // e.g. ".hls"
Developing the plugin
See How to develop and the Plugin Development Guide.