Skip to content
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

Closed
keeponZhang opened this issue Nov 2, 2018 · 2 comments
Assignees

Comments

@keeponZhang
Copy link

OsVersion==4.4.4 PhoneVersion==SM-G7200
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) {e.printStackTrace(); }

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

@ojw28
Copy link
Contributor

ojw28 commented Nov 2, 2018

I don't see any negative timestamps in the content, so I think this must be related to DefaultAudioSink timing somehow?

@andrewlewis
Copy link
Collaborator

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.

ojw28 pushed a commit that referenced this issue Nov 6, 2018
Issue: #5045

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=220237752
ojw28 pushed a commit that referenced this issue Nov 7, 2018
Issue: #5045

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=220237752
@google google locked and limited conversation to collaborators May 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants