为什么mediaplayer getcurrentposition的回报率比以前低



我正试图制作一个显示播放位置的搜索栏,但我发现了一些奇怪的东西。当前头寸的价值并不重要。应该增加asc。

记录

D/RecordingFragment: #@ current_position: 0
D/RecordingFragment: #@ current_position: 0
D/RecordingFragment: #@ current_position: 0
D/RecordingFragment: #@ current_position: 5
D/RecordingFragment: #@ current_position: 15
D/RecordingFragment: #@ current_position: 27
D/RecordingFragment: #@ current_position: 37
D/RecordingFragment: #@ current_position: 49
D/RecordingFragment: #@ current_position: 61
D/RecordingFragment: #@ current_position: 73
D/RecordingFragment: #@ current_position: 84
D/RecordingFragment: #@ current_position: 96
D/RecordingFragment: #@ current_position: 108
D/RecordingFragment: #@ current_position: 118
D/RecordingFragment: #@ current_position: 129
D/RecordingFragment: #@ current_position: 141
D/RecordingFragment: #@ current_position: 153
D/RecordingFragment: #@ current_position: 165
D/RecordingFragment: #@ current_position: 177
D/RecordingFragment: #@ current_position: 188
D/RecordingFragment: #@ current_position: 199
D/RecordingFragment: #@ current_position: 210
D/RecordingFragment: #@ current_position: 221
D/RecordingFragment: #@ current_position: 232
D/RecordingFragment: #@ current_position: 243
D/RecordingFragment: #@ current_position: 254
D/RecordingFragment: #@ current_position: 145 <- why?
D/RecordingFragment: #@ current_position: 156
D/RecordingFragment: #@ current_position: 168
D/RecordingFragment: #@ current_position: 180
D/RecordingFragment: #@ current_position: 191
D/RecordingFragment: #@ current_position: 203
D/RecordingFragment: #@ current_position: 217
D/RecordingFragment: #@ current_position: 228
D/RecordingFragment: #@ current_position: 239
D/RecordingFragment: #@ current_position: 250
D/RecordingFragment: #@ current_position: 262
D/RecordingFragment: #@ current_position: 274
D/RecordingFragment: #@ current_position: 285
D/RecordingFragment: #@ current_position: 296
D/RecordingFragment: #@ current_position: 308
D/RecordingFragment: #@ current_position: 320
D/RecordingFragment: #@ current_position: 332
D/RecordingFragment: #@ current_position: 343
D/RecordingFragment: #@ current_position: 354
D/RecordingFragment: #@ current_position: 365

这是片段代码

// update position in every 10ms
private fun updateCurrentPosition() {
timer = Timer("current_position", false).schedule(0, 10) {
Log.d(LOG_TAG, "#@ current_position 타이머: ${player.currentPosition}")
recordingViewModel.currentPosition.postValue(player.currentPosition)
}
}

观察代码

recordingViewModel.currentPosition.observe(this, Observer { position ->
if(position != null) {
sbPlayingControll.progress = position
}
})

音频文件格式(它是从MediaRecorder 录制的音频文件

setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP)
setAudioEncoder(MediaRecorder.AudioEncoder.AMR_WB)
setAudioSamplingRate(1000 * 16)
setAudioEncodingBitRate(1000 * 128)

之所以会发生这种情况,是因为您必须流式传输实时内容,并且清单刷新会定期进行,每次清单刷新时,清单中的一些块将从顶部删除,而一些新块将在底部添加。getCurrentPosition((返回该特定清单的玩家的绝对位置。因此它在每次清单刷新时都会略有减少。

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:7
#EXT-X-MEDIA-SEQUENCE:8779957
#EXTINF:6.006,
index_1_8779957.ts?m=1566416212
#EXTINF:6.006,
**index_1_8779958.ts?m=1566416212**. -- current position
#EXTINF:5.372,
index_1_8779959.ts?m=1566416212
#EXT-OATCLS-SCTE35:/DAlAAAAAsvhAP/wFAXwAAAGf+/+AdLfiP4AG3dAAAEBAQAAXytxmQ==
#EXT-X-CUE-OUT:20.020
#EXTINF:0.634,
index_1_8779960.ts?m=1566416212
#EXT-X-CUE-OUT-CONT:ElapsedTime=0.634,Duration=21,SCTE35=/DAlAAAAAsvhAP/wFAXwAAAGf+/+AdLfiP4AG3dAAAEBAQAAXytxmQ==
#EXTINF:6.006,
index_1_8779961.ts?m=1566416212
#EXT-X-CUE-OUT-CONT:ElapsedTime=6.640,Duration=21,SCTE35=/DAlAAAAAsvhAP/wFAXwAAAGf+/+AdLfiP4AG3dAAAEBAQAAXytxmQ==

清单刷新后

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:7
#EXT-X-MEDIA-SEQUENCE:8779957
#EXTINF:6.006,
**index_1_8779958.ts?m=1566416212**. -- updated current position
#EXTINF:5.372,
index_1_8779959.ts?m=1566416212
#EXT-OATCLS-SCTE35:/DAlAAAAAsvhAP/wFAXwAAAGf+/+AdLfiP4AG3dAAAEBAQAAXytxmQ==
#EXT-X-CUE-OUT:20.020
#EXTINF:0.634,
index_1_8779960.ts?m=1566416212
#EXT-X-CUE-OUT-CONT:ElapsedTime=0.634,Duration=21,SCTE35=/DAlAAAAAsvhAP/wFAXwAAAGf+/+AdLfiP4AG3dAAAEBAQAAXytxmQ==
#EXTINF:6.006,
index_1_8779961.ts?m=1566416212
#EXT-X-CUE-OUT-CONT:ElapsedTime=6.640,Duration=21,SCTE35=/DAlAAAAAsvhAP/wFAXwAAAGf+/+AdLfiP4AG3dAAAEBAQAAXytxmQ==

相关内容

  • 没有找到相关文章

最新更新