我想确切地timestamp
下一首歌曲何时播放,而当前歌曲接近尾声。我正在使用
实现 'com.google.android.exoplayer:exoplayer:r2.5.3'
在按钮单击时,我打印了这样的日志:
Log.e("TAG", "Duration: " + (mPlayer.getDuration() / 1000) + "s.");
Log.e("TAG", "Current: " + (mPlayer.getContentPosition() / 1000) + "s.");
Log.e("TAG", "Left: " + ((mPlayer.getDuration() - mPlayer.getContentPosition()) / 1000) + "s.");
这是我得到的:
D: => 在视频点击
E:持续时间:287秒。
E:电流:0秒。
E:左:286秒。
D: => 在视频点击
E:持续时间:287秒。
E:电流:6s。
E:左:281秒。
再次检查您的计算。祝你好运!
更新:
我再次检查了一下,看起来我得到了正确的时间:
14:43:27 - onVideoTapped() => onVideoTapped
14:43:27 - log() => Duration: 596s. Current: 595s.
14:43:27 - log() => Left: 1s.
14:43:28 - onTracksChanged() => currentWindowIndex: 1 nextWindowIndex: 2 isPlayBackStateReady: true
14:43:28 - log() => Duration: 596s. Current: 596s.
14:43:28 - log() => Left: 0s.
14:43:31 - onVideoTapped() => onVideoTapped
14:43:31 - log() => Duration: 510s. Current: 2s.
14:43:31 - log() => Left: 507s.