标准VideoView播放示例
本文地址: http://blog.csdn.net/caroline_wendy
在Android SDK中的ApiDemos内, 提供标准播放视频的代码,使用VideoView实现简单的视频播放功能.
代码如下:
public class VideoViewDemo extends Activity { /** * TODO: Set the path variable to a streaming video URL or a local media * file path. */ private VideoView mVideoView; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.videoview); mVideoView = (VideoView) findViewById(R.id.surface_view); /* * Alternatively, you can use mVideoView.setVideoPath(<path>); */ mVideoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.videoviewdemo)); mVideoView.setMediaController(new MediaController(this)); mVideoView.requestFocus(); } }
时间: 2024-12-16 07:30:02