简体   繁体   中英

How to resume video playback after the surface was destroyed?

I'm working with the media player on a streaming application (RTSP):

Video and sound are played great but when an incoming call pauses the Activity , the Surface is destroyed (I know this because of traces in SurfaceHolder.Callback ).

Once the call finishes, the activity is resumed and a new Surface is created. I've tried to assign it to the player via setDisplay(SurfaceHolder sh) method but so far, only the sound of the video can be heard.

The work around to resume a video stream is:

  • Restart the MediaPlayer object.
  • Wait for the buffer to fill.
  • Perform a seek via the mediaPlayer.
  • Wait for the buffer to fill.

This is annoying as the player should be able to be paused when a call is received, bind the new surface when the call completed and the Activity resume and play the video with no buffering at all.

Have you tried overriding "onStop" or even "onDestroy" and somehow make the player persitent? Edith just showed me the timestamp of this question. Is it of any interest still?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM