我正在尝试制作一个显示播放位置的搜索栏,但我发现了一些奇怪的东西。当前位置的价值不会增加。应该按 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==