-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
player.getCurrentPosition() incorrect,sometims return value is negative when play a short mp3 file #5045
Comments
I don't see any negative timestamps in the content, so I think this must be related to |
This is reproducible on ms01ltezh running JLS36C. The cause seems to be that the decoder outputs a final buffer with the end-of-stream flag set and timestamp 0. The default audio sink interprets this timestamp as a position discontinuity and adjusts its start media time, which in turn leads to the player position becoming negative. I'll see if there's a workaround to fix the erroneous output buffer info. |
Issue: #5045 ------------- Created by MOE: https:/google/moe MOE_MIGRATED_REVID=220237752
Issue: #5045 ------------- Created by MOE: https:/google/moe MOE_MIGRATED_REVID=220237752
OsVersion==4.4.4 PhoneVersion==SM-G7200
{e.printStackTrace(); }
ExoPlayer version: v2.9.0
The sample code is :
DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory selectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
TrackSelector trackSelector = new DefaultTrackSelector(selectionFactory);
mCurrentPlayer = ExoPlayerFactory.newSimpleInstance(TestActivity.this, trackSelector);
PlaybackParameters playbackParameters = new PlaybackParameters(1.0f, 1.0F);
mCurrentPlayer.setPlaybackParameters(playbackParameters);
try {
String url = "http://ep.dzb.ciwong.com/rep/38F79B83_E117_4727_A541_7642C18801CD.mp3";
mCurrentPlayer.prepare(getMediaSource(url)); mCurrentPlayer.addListener(mEventListener);
mCurrentPlayer.setPlayWhenReady(true);
} catch (Exception e)
private BaseMediaSource getMediaSource(String url)
{ BaseMediaSource mediaSource = null; try { DefaultDataSourceFactory defaultDataSourceFactory = new DefaultDataSourceFactory(DemoApplication.getInstance(), Util.getUserAgent(DemoApplication.getInstance(), DemoApplication.getInstance().getString(R.string.application_name))); mediaSource = new ExtractorMediaSource(Uri.parse(url), defaultDataSourceFactory, new DefaultExtractorsFactory(), null, null); } catch (Exception e) { e.printStackTrace(); } return mediaSource; }
protected void playListener() {
if (mCurrentPlayer != null && mCurrentPlayer.getPlaybackState() == Player.STATE_READY
&& mCurrentPlayer.getPlayWhenReady()) {
Log.e(TAG, "getDuration ==" + (long) mCurrentPlayer.getDuration()
+ " getCurrentPosition ==" + (long) mCurrentPlayer.getCurrentPosition()
+" getCurrentWindowIndex ==" + (long)
mCurrentPlayer.getCurrentWindowIndex());
mHandler.postDelayed(new Runnable() {
public void run() {
playListener();
}
}, 200L);
}
``
38F79B83_E117_4727_A541_7642C18801CD.zip
}``
the log when play the mp3
getDuration ==1645 getCurrentPosition ==71
getDuration ==1645 getCurrentPosition ==71
getDuration ==1645 getCurrentPosition ==526
getDuration ==1645 getCurrentPosition ==728
getDuration ==1645 getCurrentPosition ==930
getDuration ==1645 getCurrentPosition ==1124
getDuration ==1645 getCurrentPosition ==-307
getDuration ==1645 getCurrentPosition ==-102
getDuration ==1645 getCurrentPosition ==100
getDuration ==1645 getCurrentPosition ==301
getDuration ==1645 getCurrentPosition ==493
getDuration ==1645 getCurrentPosition ==696
getDuration ==1645 getCurrentPosition ==900
getDuration ==1645 getCurrentPosition ==1103
getDuration ==1645 getCurrentPosition ==1295
getDuration ==1645 getCurrentPosition ==1498
The text was updated successfully, but these errors were encountered: