[Need Support]Need support on finding data from player

Hi Support Team,

Could you please assist me in obtaining the following information:

  1. Buffer Status
  2. Buffer Length
  3. Current Bitrate

Please suggest an API for achieving this.

We are working on the Android Platform using Kotlin as the programming language.

Regarding the bitrate, currently, I am utilizing player?.source?.selectedVideoQuality?.bitrate, but it consistently returns a value of -1, which is not the expected behavior.

Hi,

Thank you for reaching out to our community.

Here are the APIs we can use to check the buffer and bitrate information, along with examples in Kotlin.

Buffer Status

  • We can use the isStalled API doc to check the buffer status. If player is in a low buffering condition and needs more data, the flag becomes true.
    Log.i("LOG", "isStalled (${player.isStalled})")

    # output example
    # isStalled (true)
  • We can also subscribe the StallStarted (doc) / StallEnded (doc) events to dynamically monitor the buffering status as shown below.
    private fun addEventListener() {
        player.on<PlayerEvent.StallStarted>(::onStallStarted)
        player.on<PlayerEvent.StallEnded>(::onStallEnded)
    }
    private fun removeEventListener() {
        player.off(::onStallStarted)
        player.off(::onStallEnded)
    }
    private fun onStallStarted(playerEvent: PlayerEvent) {
        Log.i("LOG", "buffering started ($playerEvent)")
    }
    private fun onStallEnded(playerEvent: PlayerEvent) {
        Log.i("LOG", "buffering ended ($playerEvent)")
    }

Buffer Length

  • We can use the getLevel API (doc) to check the current and target buffer lengths for video and audio. There are two buffer type, forward buffer and backward buffer, and we can check both values as follows.
    val videoForwardBuffer = player.buffer.getLevel(BufferType.ForwardDuration, MediaType.Video)
    val videoBackwardBuffer = player.buffer.getLevel(BufferType.BackwardDuration, MediaType.Video)
    val audioForwardBuffer = player.buffer.getLevel(BufferType.ForwardDuration, MediaType.Audio)
    val audioBackwardBuffer = player.buffer.getLevel(BufferType.BackwardDuration, MediaType.Audio)

    Log.i("LOG", "video buffer: forward (${videoForwardBuffer})")
    Log.i("LOG", "video buffer: backward (${videoBackwardBuffer})")
    Log.i("LOG", "audio buffer: forward (${audioForwardBuffer})")
    Log.i("LOG", "audio buffer: backward (${audioBackwardBuffer})")

    # output example
    # video buffer: forward (BufferLevel(level=51.740666, targetLevel=50.0, media=Video, type=ForwardDuration))
    # video buffer: backward (BufferLevel(level=0.30100000000000016, targetLevel=0.0, media=Video, type=BackwardDuration))
    # audio buffer: forward (BufferLevel(level=53.187, targetLevel=50.0, media=Audio, type=ForwardDuration))
    # audio buffer: backward (BufferLevel(level=0.3810000000000002, targetLevel=0.0, media=Audio, type=BackwardDuration))

Current Bitrate

  • We can use the playbackVideoData API (doc) and playbackAudioData API (doc) to check the current playback quality, including bitrate. The selectedVideoQuality API (doc) can show the bitrate value when a video quaity is selected by user from the player UI’s select box.
    Log.i("LOG", "current video quality (${player.playbackVideoData})")
    Log.i("LOG", "current audio quality (${player.playbackAudioData})")

    # output example
    # current video quality (VideoQuality(id=1080p 6000kbps, label=1920x818, 6214kbps, bitrate=6214307, codec=avc1.4D4028, frameRate=24.0, width=1920, height=818))
    # current audio quality (AudioQuality(id=128kbps en, label=128kbps, bitrate=128189, codec=mp4a.40.2))

Hope it helps and please feel free to ask if you have any questions. Thank you.

Best Regards,
Kazuhide