3

I have a activity who hold 2 fragments (one SlidingMenu and other a VideoPlayer with control and other views).

How Can I retain the video playing status when I'm rotating the device? the video is a HLS Stream, so, I don't need to start again the buffering when rotate.

I start playing with the savedInstanceState, but i can't get it work

Rodrigo Amaro Reveco
  • 4,932
  • 5
  • 22
  • 33

1 Answers1

2

If you are using the same resources on on different screen orientations, you can prevent fragment from recreating.

If you need to recreate fragment, you can store playback progress, and after recreation scroll video to stored position

@Override
protected void onPause() {
    ...
    if(playbackWasStarted) {
        video.pause();
        videoProgress = video.getCurrentPosition();
    }
    ...
}

@Override
protected void onResume() {
    ...
    if(playbackWasStarted && videoProgress!=0) {
        video.seekTo(videoProgress);
        video.start();
    }
    ...
}

EDIT Oh, I didn't noticed that this question is veeeery old...

Community
  • 1
  • 1
ooops
  • 326
  • 2
  • 14