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

setBackgrounded(true) not working as expected in HLS video. (Video and audio downloading mismatch, while coming back to activity ) #1698

Closed
saurabhkpatel opened this issue Jul 26, 2016 · 3 comments

Comments

@saurabhkpatel
Copy link

saurabhkpatel commented Jul 26, 2016

@ojw28 Need your comments or suggestions, on below issue.

I am trying to run background audio playback when a user leaves video player activity. I wrote service for that and I am handling ExoPlayer in service, Background play is working fine when I leave application at that time I am setting "setBackgrounded(true)" . When I am returning back to an application and open video player activity, here first I am checking if something is playing or not in service, if yes then use "setBackgrounded(false)" and attach surfaceView to show video.

In the above-described method, I am facing two problems, which I discussed below.

Reproduce steps in ExoPlayer demo application :

  1. Start demo application, go HLS section, select first video name "Apple master playlist".
  2. play this video.
  3. pause this video at any time and note down MM:SS from seekbar and video display. [refer before.png]
  4. Press home screen, by doing this activity goes to onResume() method and below code will be executed
if (!enableBackgroundAudio) {
  releasePlayer();
} else {
  player.setBackgrounded(true);
}
shutterView.setVisibility(View.VISIBLE);
}

Note : It will set player in background mode as I enabled enableBackgroundAudio=true.

  1. After few seconds come back to ExoPlayer Demo application by pressing "Overview" button and select ExoPlayer from it. Now compare seek-bar time and time which video frame displays. [Refer after.png file]

Problem 1 : Both are different, now press the play button and you can see video frame will not refresh until seek bar will not sync with it.

It means the video frames are still downloading/rendering when a player is paused and setBackgrounded is true.

Problem 2 : In step three if we won't pause a video and put an application in background mode and come back to the application, audio is playing and it's perfectly fine but when I came back to exoplayer demo application (foreground mode), I can see video frame is getting freeze for few seconds (5-6 seconds, sometimes I can see only black screen). It will be in sync with the seek bar after few seconds. (In this case also, audio and video downloading rate are different.)

Is this problem of audio and video downloading mismatch or video downloading happening with pause and setBackgrounded(true).

There any workaround to solve this problem?

You can find changes in demo application over here : saurabhkpatel@78b7c66

Attachments :

Before.png

before

After.png

after

@saurabhkpatel saurabhkpatel changed the title setBackgrounded(true) not working as expected in HLS video. (Video frame does not render for a while, after coming back to activity) setBackgrounded(true) not working as expected in HLS video. (Video and audio downloading mismatch, while coming back to activity ) Jul 26, 2016
@saurabhkpatel
Copy link
Author

@ojw28 Is there any update on this issue, I posted 1 week before. If you require more information about this then please let me know i can provide you more details.

@ojw28
Copy link
Contributor

ojw28 commented Jun 24, 2017

This is basically boils down to being able to smoothly switch/detach/attach surfaces, which is discussed and tracked in #677.

Note: You appear to be using ExoPlayer V1 still, which is pretty old at this point. You should consider migrating to V2, where we've been making improvements in this area.

@ojw28 ojw28 closed this as completed Jun 24, 2017
@saurabhkpatel
Copy link
Author

@ojw28 : First of thanks for your reply on this thread after more than 11 Months. I reported this issue last summer at that time version 2 was not out.
I will try with version 2 and update the information in the new thread if require.

@google google locked and limited conversation to collaborators Oct 23, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants