mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-31 15:19:34 +02:00
Change:Audio stream buffer times #63
This commit is contained in:
parent
0fcec4b861
commit
1a7f90c93b
3 changed files with 25 additions and 1 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue