Change:Audio stream buffer times #63

This commit is contained in:
advplyr 2021-12-19 12:40:52 -06:00
parent 0fcec4b861
commit 1a7f90c93b
3 changed files with 25 additions and 1 deletions

View file

@ -82,8 +82,10 @@ class MyNativeAudio : Plugin() {
fun getCurrentTime(call: PluginCall) {
Handler(Looper.getMainLooper()).post() {
var currentTime = playerNotificationService.getCurrentTime()
var bufferedTime = playerNotificationService.getBufferedTime()
val ret = JSObject()
ret.put("value", currentTime)
ret.put("bufferedTime", bufferedTime)
call.resolve(ret)
}
}

View file

@ -243,7 +243,15 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
ctx = this
// Initialize player
var customLoadControl:LoadControl = DefaultLoadControl.Builder().setBufferDurationsMs(
1000 * 20, // 20s min buffer
1000 * 45, // 45s max buffer
1000 * 5, // 5s playback start
1000 * 20 // 20s playback rebuffer
).build()
var simpleExoPlayerBuilder = SimpleExoPlayer.Builder(this)
simpleExoPlayerBuilder.setLoadControl(customLoadControl)
simpleExoPlayerBuilder.setSeekBackIncrementMs(10000)
simpleExoPlayerBuilder.setSeekForwardIncrementMs(10000)
mPlayer = simpleExoPlayerBuilder.build()
@ -694,6 +702,10 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
return currentPlayer.currentPosition
}
fun getBufferedTime() : Long {
return currentPlayer.bufferedPosition
}
fun getTheLastPauseTime() : Long {
return lastPauseTime
}