-2

Possible Duplicate:
How to continue video play while orientation change in android

I'm just playing an rtsp video on android default player.Halfly, when i change orientation into landscape,it starts streaming from beginning.How could i do continue playing.I gave androidconfig="orientation" on manifest file.But still happens same.What else i need to do for that?

My code:

private String vSource="http://commonsware.com/misc/test2.3gp";

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    // sets the Bundle
    super.onCreate(savedInstanceState);
    // sets the context
    setContentView(R.layout.main);
    myVideoView= (VideoView)findViewById(R.id.vview);
       myVideoView.setVideoURI(Uri.parse(vSource));
       myVideoView.setMediaController(new MediaController(this));
       myVideoView.requestFocus();
       myVideoView.start();


}

public void onSaveInstanceState(Bundle outState){

    mStartTime = myVideoView.getCurrentPosition();
    outState.putInt("restartTime", mStartTime);
    super.onSaveInstanceState(outState);
}
 @Override
    public void onRestoreInstanceState(Bundle savedInstanceState) {
      super.onRestoreInstanceState(savedInstanceState);
      myInt  = savedInstanceState.getInt("restartTime");

 }

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);


      myVideoView.seekTo(myInt);

      myVideoView.start();


}

Thanks.

Community
  • 1
  • 1
sanjay
  • 2,590
  • 17
  • 55
  • 88
  • 2
    You already posted this yesterday http://stackoverflow.com/questions/11629556/how-to-continue-video-play-while-orientation-change-in-android/11629668#11629668 – Adam Monos Jul 25 '12 at 09:34

1 Answers1

1

You can store the actual progress of your video in onSaveInstanceState (called when the activity is destroyed, like when the screen is rotated), then restore it in onRestoreInstanceState.

Dalmas
  • 26,409
  • 9
  • 67
  • 80