doublesymmetry / KotlinAudio

KotlinAudio is an Android audio player written in Kotlin, making it simpler to work with audio playback from streams and files.
Apache License 2.0
44 stars 70 forks source link

BackBuffer Not Working? #99

Closed Tr736 closed 9 months ago

Tr736 commented 11 months ago

Hi,

Im currently trying to avoid buffering when I seek backwards by 10s. However when I seek back, the item buffers resulting in a position of 0 and the seek bar jumping from current position to 0 back to seeked position.

This is how im setting the buffer atm

`fun setupPlayer(playerOptions: Bundle?) { val bufferConfig = BufferConfig( playerOptions?.getDouble(MIN_BUFFER_KEY)?.toMilliseconds()?.toInt(), playerOptions?.getDouble(MAX_BUFFER_KEY)?.toMilliseconds()?.toInt(), playerOptions?.getDouble(PLAY_BUFFER_KEY)?.toMilliseconds()?.toInt(), playerOptions?.getDouble(BACK_BUFFER_KEY)?.toMilliseconds()?.toInt(), )

    val cacheConfig = CacheConfig(playerOptions?.getDouble(MAX_CACHE_SIZE_KEY)?.toLong())
    val playerConfig = PlayerConfig(
            interceptPlayerActionsTriggeredExternally = true,
            handleAudioBecomingNoisy = true,
            handleAudioFocus = true,
            audioContentType =  AudioContentType.SPEECH // Setting this will result in pausing the audio rather then ducking
            }
    )
    val automaticallyUpdateNotificationMetadata = false

    player = QueuedAudioPlayer(this@MusicService, playerConfig, bufferConfig, cacheConfig)
    player.automaticallyUpdateNotificationMetadata = automaticallyUpdateNotificationMetadata
    if (playerInitialized == false) {
        observeEvents()
    }
    playerInitialized = true
}`

the values im passing in

minBuffer : 1000 * 30 // 30s
maxBuffer:   1000 * 60 * 10 // 10min
backBuffer:  1000 * 60 * 5 // 5min
playBuffer: 1000 * 30 // 30s