0

I am playing videos in my app, video should play portrait and landscape mode withought restarting actvity, please any can give examples are links.

  • using video view for playing video.

    public class PlayVideoActivity extends Activity {
    
    private VideoView video;
    private ImageButton back;
    
    
    
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);  
        setContentView(R.layout.main);
    
    
        back = (ImageButton)findViewById(R.id.backbutton);
        back.setOnClickListener(new View.OnClickListener() {
    
            public void onClick(View arg0) {
    
                finish();
            }
        });
    
        video=(VideoView)findViewById(R.id.videoView);
    
    
    
        video.setDrawingCacheEnabled(true);
        video.setDrawingCacheQuality(VideoView.DRAWING_CACHE_QUALITY_HIGH);
    
        video.setVideoURI(Uri.parse("android.resource://"+ getPackageName() +"/" + R.raw.fillings_class_1));
        video.requestFocus();
        video.setMediaController(new MediaController(this));
        video.start();
    
    }
    
    
       @Override
       public void onRestoreInstanceState(Bundle savedInstanceState) {
           super.onRestoreInstanceState(savedInstanceState);
           //restore the relevant information
    
       }
    
    
    
    }
    
Blundell
  • 75,855
  • 30
  • 208
  • 233

1 Answers1

0

If you really need to prevent the activity from being restarted on an orientation change, you need to set the configChanges attribute for the Activity in the manifest to include orientation.

K-ballo
  • 80,396
  • 20
  • 159
  • 169