我在我的应用程序中播放视频,视频应该播放纵向和横向模式而不需要重新启动活动,请任何可以给出示例的链接。
使用视频视图播放视频。
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 } }