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() return value is negative when using ClippingMediaSource #4873

Closed
Romantic-LiXuefeng opened this issue Sep 27, 2018 · 7 comments
Assignees
Labels

Comments

@Romantic-LiXuefeng
Copy link

Romantic-LiXuefeng commented Sep 27, 2018

ExoPlayer version: v2.8.4
The sample code is :

 MediaSource[] mediaSources = new MediaSource[uris.length];
 for (int i = 0; i < uris.length; i++) {
     mediaSources[i] = buildMediaSource(uris[i], extensions[i], null);
 }
 if (mediaSources.length == 1){
    ClippingMediaSource content1 = new ClippingMediaSource(mediaSources[0], 0, 15000000,null);
    ClippingMediaSource content2 = new ClippingMediaSource(mediaSources[0], 15000000, C.TIME_END_OF_SOURCE,null);
    mediaSource = new ConcatenatingMediaSource(
          content1,            // content[0~15s]
          content2 );           // content[15s ~ end]
}

I use a ClippingMediaSource to split one video into two video at point 15s, then concatenate them.
When the player begins to play the second video, I pressed home button, then resume to play, I find
that the TimeBar's current position is negative. The logs like this:

  E/EventLogger: player position = [-6421] bufferedPosition = [-1742]
  E/EventLogger:player position = [-5006] bufferedPosition = [4760]
@Romantic-LiXuefeng
Copy link
Author

@ojw28 Did you already had the time to look into this issue? Is there anything I can do to support you?

@erdemguven
Copy link
Contributor

Reproducible on the latest development branch.

@tonihei
Copy link
Collaborator

tonihei commented Sep 28, 2018

Thanks for reporting. We'll provide a fix for this soon.

ojw28 pushed a commit that referenced this issue Oct 1, 2018
…o offset.

If we prepare a deferred media period before the actual timeline is available,
we either prepare with position zero (= the default) or with a non-zero
initial seek position.

So far, the zero (default) position got replaced by the actual default position
(including any potential non-zero window offset) when the timeline became known.

However, a non-zero initial seek position was not corrected by the non-zero
window offset. This is fixed by this change.

Related to that, we always assumed that the deferred media period will the
first period in the actual timeline. This is not true if we prepare with an
offset (either because of an initial seek position or because of a default
window position). So, we also determine the actual first period when the
timeline becomes known.

Issue:#4873

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=215213030
@tonihei
Copy link
Collaborator

tonihei commented Oct 2, 2018

The commit above fixes the issue.

@tonihei tonihei closed this as completed Oct 2, 2018
@Romantic-LiXuefeng
Copy link
Author

@tonihei thanks! Hope to give me some information about how was this bug generated?

@Romantic-LiXuefeng
Copy link
Author

Romantic-LiXuefeng commented Oct 9, 2018

@ojw28 I find that when the player plays the first clip video ,press home button, then resume to play,there is no this bug. Hope you give me some explanation.

@tonihei
Copy link
Collaborator

tonihei commented Oct 11, 2018

The bug occurred because the player creates the element at which playback starts with a default position of zero until we know more. In your case, this default position was non-zero (because of the clipping) and we forgot to set the right offset at one point.

Not sure why you don't see the bug with the first video? I was able to reproduce the issue with the first and the second video in a concatenation.

ojw28 pushed a commit that referenced this issue Oct 20, 2018
…o offset.

If we prepare a deferred media period before the actual timeline is available,
we either prepare with position zero (= the default) or with a non-zero
initial seek position.

So far, the zero (default) position got replaced by the actual default position
(including any potential non-zero window offset) when the timeline became known.

However, a non-zero initial seek position was not corrected by the non-zero
window offset. This is fixed by this change.

Related to that, we always assumed that the deferred media period will the
first period in the actual timeline. This is not true if we prepare with an
offset (either because of an initial seek position or because of a default
window position). So, we also determine the actual first period when the
timeline becomes known.

Issue:#4873

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

No branches or pull requests

3 participants