# \[Need Support\]Need support on finding data from player

**URL:** <https://community.bitmovin.com/t/need-support-need-support-on-finding-data-from-player/2838>\
**Category:** Support\
**Tags:** android\
**Created:** [April 24, 2024, 5:35am UTC](https://community.bitmovin.com/t/need-support-need-support-on-finding-data-from-player/2838 "2024-04-24T05:35:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![iamvivekpro](https://avatars.discourse-cdn.com/v4/letter/i/c77e96/32.png) [@iamvivekpro](https://community.bitmovin.com/u/iamvivekpro)\
**Post date:** [April 24, 2024, 5:35am UTC](https://community.bitmovin.com/t/need-support-need-support-on-finding-data-from-player/2838/1 "2024-04-24T05:35:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kazuhide](https://sea1.discourse-cdn.com/flex015/user_avatar/community.bitmovin.com/kazuhide/32/263_2.png) [@kazuhide](https://community.bitmovin.com/u/kazuhide)\
**Post date:** [April 25, 2024, 1:47am UTC](https://community.bitmovin.com/t/need-support-need-support-on-finding-data-from-player/2838/2 "2024-04-25T01:47:09Z")

</div>

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](https://cdn.bitmovin.com/player/android/3/docs/player-core/com.bitmovin.player.api/-player/is-stalled.html?query=abstract%20val%20isStalled:%20Boolean) to check the buffer status. If player is in a low buffering condition and needs more data, the flag becomes `true`.

```auto
    Log.i("LOG", "isStalled (${player.isStalled})")

    # output example
    # isStalled (true)

```

- We can also subscribe the **StallStarted** ([doc](https://cdn.bitmovin.com/player/android/3/docs/player-core/com.bitmovin.player.api.event/-player-event/-stall-started/index.html?query=class%20StallStarted%20:%20PlayerEvent)) / **StallEnded** ([doc](https://cdn.bitmovin.com/player/android/3/docs/player-core/com.bitmovin.player.api.event/-player-event/-stall-ended/index.html)) events to dynamically monitor the buffering status as shown below.

```auto
    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](https://cdn.bitmovin.com/player/android/3/docs/player-core/com.bitmovin.player.api.buffer/-buffer-api/get-level.html?query=abstract%20fun%20getLevel(type:%20BufferType,%20media:%20MediaType):%20BufferLevel)) 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.

```auto
    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](https://cdn.bitmovin.com/player/android/3/docs/player-core/com.bitmovin.player.api/-player/playback-video-data.html?query=abstract%20val%20playbackVideoData:%20VideoQuality)) and **playbackAudioData** API ([doc](https://cdn.bitmovin.com/player/android/3/docs/player-core/com.bitmovin.player.api/-player/playback-audio-data.html)) to check the current playback quality, including bitrate. The **selectedVideoQuality** API ([doc](https://cdn.bitmovin.com/player/android/3/docs/player-core/com.bitmovin.player.api.source/-source/selected-video-quality.html?query=abstract%20val%20selectedVideoQuality:%20VideoQuality)) can show the bitrate value when a video quaity is selected by user from the player UI’s select box.

```auto
    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
