0

我在我的应用程序中播放视频,视频应该播放纵向和横向模式而不需要重新启动活动,请任何可以给出示例的链接。

  • 使用视频视图播放视频。

    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
    
       }
    
    
    
    }
    
4

1 回答 1

0

如果确实需要防止 Activity 在方向更改时重新启动,则需要将configChanges清单中 Activity 的属性设置为 include orientation

于 2012-05-22T21:22:36.500 回答