5

Exoplayer  AAC(ADTS/ADTS)/ AMR media duration

 9 months ago
source link: https://i.lckiss.com/?p=8293
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Exoplayer  AAC(ADTS/ADTS)/ AMR media duration

抬头仰望星空,是否能发现自己的渺小。

伪斜杠青年

Exoplayer  AAC(ADTS/ADTS)/ AMR media duration

2023-10-09

Exoplayer 对于 AAC(ADTS/ADTS),AMR 默认不支持时长以及定位解析,如果有需求,需要自行开启恒定比特率定位:

DefaultExtractorsFactory().setConstantBitrateSeekingEnabled(true) 

应用于构建函数第二个参数:

SimpleExoPlayer.Builder(context, DefaultExtractorsFactory().setConstantBitrateSeekingEnabled(true))
.build()

使用时通过 Listener 在 STATE_READY 状态进行获取,默认为 ms :

 var playerListener: Player.Listener = object : Player.Listener {

        override fun onPlaybackStateChanged(state: Int) {
            if (state == ExoPlayer.STATE_READY) {
                val duration = mPlayer?.duration ?: 0L
                val length = if (duration < 0) {
                    0L
                } else {
                    duration / 1000
                }
                listener?.onAudioLength(length)
            } else {
                if (state == Player.STATE_ENDED) {
                    listener?.onComplete()
                }
            }
        }
    }

https://exoplayer.dev/progressive.html#enabling-constant-bitrate-seeking

深入解读ExoPlayer 之 开发者指南全译-03 媒体类型


本站由以下主机服务商提供服务支持:

作者:Mosaic-C

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK