AndroidプレーヤーSDK

API Reference

Index

Player initialize/uninitialize and load media

Initialize | UninitializeLoad media source

Playback control

PlayPauseSeekForwardRewind

Set Player Parameters

Set Quality | Set Subtile | Set Audio Track

Set VolumeMuteUnmute

Set Speed

Get Player Parameters

Get Media Config

Get Playing Status | Get Volume

Get Current Playback TimeGet Total Duration | Get Buffered Time

Get All QualitiesGet Current Quality

Get All SubtitlesGet Current Subtitle

Get All Audio Tracks | Get Current Audio Track

Set Event Listener/Callback

Set Playback/Error Event Callback

Set Playlog Event Callback

 

 

Initialize

  • Initialize a player instance.
UniPlayer.Builder([$MediaConfig]).build(): UniPlayer
  • Parameters
$MediaConfig = 
{
   val source: List<Source>,
   val title: String,
   val description: String,
   val imageUrl: String,
   val startTimeMs: Int,
   val thumbnailSeekingUrl: String,
   var contentType: ContentType,
   var defaultMediaSourceType: String,
   var defaultQuality: Int,
   var seekableOption: SeekableOption,
   var adTagParameters: Map<String, String>,
   var playWhenReady: Boolean,
   val sharedUrl: String,
   val features: List<Feature>
}

 

Uninitialize

  • Uninitialize/destroy the initialized/created player.
player.release(): Unit

 

Load media source with config

  • Set the media source config into the player.
player.load([$MediaConfig]): Unit
  • Parameters
$MediaConfig = 
{
   val source: List<Source>,
   val title: String,
   val description: String,
   val imageUrl: String,
   val startTimeMs: Int,
   val thumbnailSeekingUrl: String,
   var contentType: ContentType,
   var defaultMediaSourceType: String,
   var defaultQuality: Int,
   var seekableOption: SeekableOption,
   var adTagParameters: Map<String, String>,
   var playWhenReady: Boolean,
   val sharedUrl: String,
   val features: List<Feature>
}

 

Get media config

  • Get the media config data set to the player.
player.getCurrentMediaConfig(): MediaConfig
  • Parameters:
$MediaConfig = 
{
val source: List<Source>,
val title: String,
val description: String,
val imageUrl: String,
val startTimeMs: Int,
val thumbnailSeekingUrl: String,
var contentType: ContentType,
var defaultMediaSourceType: String,
var defaultQuality: Int,
var seekableOption: SeekableOption,
var adTagParameters: Map<String, String>,
var playWhenReady: Boolean,
val sharedUrl: String,
val features: List<Feature>
}

 

Play

  • Start the playback.
player.play(): Unit

 

Pause

  • Pause the playback.
player.pause(): Unit

 

isPlaying

  • Get the playing status of the playback.
player.isPlaying(): Boolean

 

Get Current Time

  • Get the current playback position.
player.getPosition(): Long

 

Get Total Duration

  • Get the total duration of the playback.
player.getDuration(): Long

 

Get Buffered Time

  • Get current buffered time during playback
player.getBufferedPosition(): Long

 

Seek

  • Set the playback position with the specific timestamp.
player.seek(millisecond: long): Unit

 

Forward

  • Forward the playback with the specific timestamp.
player.forward(millisecond: long): Unit

 

Rewind

  • Rewind the playback with the specific timestamp.
player.rewind(millisecond: long): Unit

 

Get Volume

  • Get the current playback volume value.
player.getVolume(): Float

 

Get Quality(ies)

  • Get all quality(ies) during playback.
player.getQualities(): List<Quality>
  • Parameters:
data class Quality {
val resolution: Resolution(width, height),
val bitrate: Int,
val frameRate: Float
}

 

Get Current Quality

  • Get the current playback quality.
player.getCurrentQuality(): Quality
  • Parameters
data class Quality {
val resolution: Resolution(width, height),
val bitrate: Int,
val frameRate: Float
}

 

Set Quality

  • Set the playback quality of the playback video.

Set specific quality

player.setQuality(height: Int?): Unit

Set auto quality adaptive

player.setQuality(null): Unit

 

Set Volume

  • Set the current playback volume value.
player.setVolume(float): Unit

 

Mute

  • Mute the playback volume.
player.mute(): Unit

 

Unmute

  • Unmute the playback volume.
player.unmute(): Unit

 

Get Audio Track(s)

  • Get all audio track(s) of the playback.
player.getAudioTracks(): List<AudioTrack>
  • Parameters:
data class AudioTrack {
val language: String
}

 

Get Current Audio Track

  • Get the current audio track of the playback.
player.getCurrentAudioTrack(): AudioTrack
  • Parameters
data class AudioTrack {
val language: String
}

 

Set Audio Track

  • Set the specific audio track of the playback.
player.setAudioTrack(language: String): Unit

 

Get Subtitle(s)

  • Get all subtitle(s) of the playback.
player.getSubtitles(): List<Subtitle>
  • Parameters
data class Subtitle {
val language: String
}

 

Get Current Subtitle

  • Get the current subtitle of the playback.
player.getCurrentSubtitle(): Subtitle
  • Parameters
data class Subtitle {
val language: String
}

 

Set Subtitle

  • Set or disable the playback subtitle of the playback video.

Set specific subtitle

player.setSubtitle(Subtitle): Unit
  • Parameters
data class Subtitle {
val language: String
}

Disable the subtitle display

player.setSubtitle("off"): Unit

 

Get Current Speed

  • Get the current playback speed value.
player.getCurrentPlaybackSpeed(): Float

 

Set Speed

  • Set the current playback speed value.
// return true if setting success; false if illegal speed setting (less than 0.0f)
player.setPlaybackSpeed(speed: Float): Boolean

 

Playback/ Error Event Callback Listener

  • Listen to the playback callback event that happened during playback. This method provides the function callback and listener to get the state of the player. Then, you can implement the customization by those states. i.e., After getting the state of buffering, you can get its preferred icon.

Playback Event Listener

player.addStateEventListener(object: StateEventListener {
override fun onPlayerStateChanged(playerState) {
// do something
}
})
  • Parameters
playerState = IDLE, READY, BUFFERING, ENDED

Error Event Listener

player.addErrorEventListener(object: ErrorEventListener {
override fun onUniError(errorEvent: UniErrorEvent): Boolean
// do something
}
})
  • Parameters
UniErrorEvent = Exception defined in Java/Kotlin

 

Playlog event callback

  • This method allows you to get the log information, and then you can integrate to the log service 
playLogger = object : PlayLogger {
override fun logEvent(eventName: String, properties: Map<String, Any>) {
// do something
}
}

 

更新