Android ExoPlayer
Cordova media player plugin using Google's ExoPlayer framework.
https://github.com/google/ExoPlayer
Repo: https://github.com/frontyard/cordova-plugin-exoplayer
Installation
- Install the Cordova and Ionic Native plugins:
$ ionic cordova plugin add cordova-plugin-exoplayer $ npm install --save @ionic-native/android-exoplayer@4
- Add this plugin to your app's module
Supported platforms
- Android
Usage
import { AndroidExoPlayer } from '@ionic-native/android-exoplayer';
constructor(private androidExoPlayer: AndroidExoPlayer) { }
...
this.androidExoPlayer.show({url: 'http://www.youtube.com/api/manifest/dash/id/bf5bb2419360daf1/source/youtube'});
Instance Members
show(parameters)
Show the player.
Param | Type | Details |
---|---|---|
parameters |
AndroidExoPlayerParams
|
Parameters |
Returns: Observable<AndroidExoplayerState>
setStream(url, controller)
Switch stream without disposing of the player.
Param | Type | Details |
---|---|---|
url |
string
|
The url of the new stream. |
controller |
AndroidExoPlayerControllerConfig
|
Configuration of the controller. |
Returns: Promise<void>
playPause()
Will pause if playing and play if paused
Returns: Promise<void>
stop()
Stop playing.
Returns: Promise<void>
seekTo(milliseconds)
Jump to a particular position.
Param | Type | Details |
---|---|---|
milliseconds |
number
|
Position in stream in milliseconds |
Returns: Promise<void>
seekBy(milliseconds)
Jump to a particular time relative to the current position.
Param | Type | Details |
---|---|---|
milliseconds |
number
|
Time in milliseconds |
Returns: Promise<void>
getState()
Get the current player state.
Returns: Promise<AndroidExoplayerState>
showController()
Show the controller.
Returns: Promise<void>
hideController()
Hide the controller.
Returns: Promise<void>
setController(controller)
Update the controller configuration.
Param | Type | Details |
---|---|---|
controller |
AndroidExoPlayerControllerConfig
|
Configuration of the controller. |
Returns: Promise<void>
close()
Close and dispose of player, call before destroy.
Returns: Promise<void>
AndroidExoPlayerParams
Param | Type | Details |
---|---|---|
url |
string
|
Url of the video to play. |
userAgent |
string
|
Set the user agent. Default is |
aspectRatio |
AndroidExoPlayerAspectRatio
|
Set the player aspect ratio. (optional) |
hideTimeout |
number
|
Hide controls after this many milliseconds, default is |
autoPlay |
boolean
|
When set to false stream will not automatically start. (optional) |
seekTo |
number
|
Start playback at this many milliseconds into video, default is |
forwardTime |
number
|
Amount of time in milliseconds to use when skipping forward, default is |
rewindTime |
number
|
Amount of time in milliseconds to use when skipping backward, default is |
audioOnly |
|
Only play audio in the backgroud, default is |
true |
|
|
subtitleUrl |
string
|
Optional subtitle url to display over the video. We currently support .srt and .vtt subtitle formats. Subtitles are not supported on all stream types, as ExoPlayer has requirement that both video and subtitle "must have the same number of periods, and must not have any dynamic windows", which means for simple mp4s it should work, but on more complex HLS/Dash setups it might not. (optional) |
connectTimeout |
number
|
okhttp connect timeout in milliseconds (default is |
readTimeout |
number
|
okhttp read timeout in milliseconds (default is |
writeTimeout |
number
|
okhttp write timeout in milliseconds (default is |
pingInterval |
number
|
okhttp socket ping interval in milliseconds (default is |
retryCount |
number
|
Number of times datasource will retry the stream before giving up (default is |
controller |
AndroidExoPlayerControllerConfig
|
If this object is not present controller will not be visible. (optional) |
AndroidExoplayerState
Param | Type | Details |
---|
AndroidExoPlayerControllerConfig
Param | Type | Details |
---|---|---|
streamImage |
string
|
Image in the controller. |
streamTitle |
string
|
|
streamDescription |
string
|
|
hideProgress |
|
Hide entire progress bar. (optional) |
true |
|
|
hidePosition |
|
If progress bar is visible hide current position from it |
false |
|
|
hideDuration |
|
If progress bar is visible Hide stream duration from it |
controlIcons |
*/
exo_ffwd: string;
}
|
Override the player control button icons. (optional) |