mozilla-mobile / android-components

⚠️ This project moved to a new repository. It is now developed and maintained at: https://github.com/mozilla-mobile/firefox-android
https://github.com/mozilla-mobile/firefox-android
Mozilla Public License 2.0
2.02k stars 473 forks source link

Seeking through a video re-sets the audio state and pauses video #4033

Closed jonalmeida closed 5 years ago

jonalmeida commented 5 years ago

STR

  1. Play a video.
  2. Move the seek bar to a different position.
  3. Observe the video is no longer playing.
  4. Press the play button.
  5. Observe the state of the video again.

Expected

At 3, the video should not pause (this is existing behaviour). At 5, the video should play immediately when we press play.

Actual

At 3, the video pauses. At 5, the video does not play after press the play button. You have to always press the play button twice.

┆Issue is synchronized with this Jira Task

pocmo commented 5 years ago

What happens internally:

Media: PLAY State: None -> Playing Service Start Requesting audio Focus (1; AUDIOFOCUS_GAIN)

Media: PAUSE State: Playing -> Pause

Media: SEEKING State: Pause-> None Service stopped

Media: PLAY State: None -> Playing Service started Requesting audio focus (1; AUDIOFOCUS_GAIN)

Audio Focus change (-1; AUDIOFOCUS_LOSS) Pausing media Media: PAUSE State: Playing -> Pause

pocmo commented 5 years ago

Two observations:

pocmo commented 5 years ago

This also makes me realize that we did not implement any abandonAudioFocus() calls. I'll start with that.

pocmo commented 5 years ago

Correctly abandoning and then re-requesting audio focus definitely fixes the issue.

The notification briefly disappears while the seek happens. So we could still keep the playing state while seeking.

pocmo commented 5 years ago

Correctly abandoning and then re-requesting audio focus definitely fixes the issue.

The notification briefly disappears while the seek happens. So we could still keep the playing state while seeking.

I'll leave it at that for now and close this issue. The issue is fixed with correctly abandoning and re-focusing. Keeping the state is more complicated and may not be necessary for now.

jonalmeida commented 5 years ago

@pocmo on r-b after this change, videos don't seem to play anymore. I'm not sure if it's related to this one though.

pocmo commented 5 years ago

@jonalmeida Mh, YouTube and Vimeo still seem to work here. Can you file this separately so that we can look into it?