我在SD卡上保存了一个视频文件。它的路径保存在我的数据库中。在运行视频文件时,我从数据库中获取路径。
我的视频路径是:
/mnt/sdcard/VideoLog/2013-01-01 11.18.57.mp4
,代码如下:
video_view_player = (VideoView) findViewById(R.id.videoview_player);
video_view_player.setVideoPath(filename);
//video_view_player.setMediaController(new MediaController(this));
//video_view_player.requestFocus();
video_view_player.start();
视频路径中的文件名是从数据库中获取的。
我甚至尝试将.mp4
视频转换为.3gp
,但徒劳无功。
答案 0 :(得分:0)
尝试这种方式:
VideoPLayer =(VideoView)findViewById(R.id.VideoPLayer);
mediaController = new MediaController(m_context);
VideoPLayer.setVideoPath(m_videoUrl);
VideoPLayer.setVideoURI(Uri.parse(videoUrl));
VideoPLayer.setMediaController(m_mediaController);
VideoPLayer.start();
mediaController.show();
答案 1 :(得分:0)
public class MainActivity extends Activity {
VideoView vv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
vv=(VideoView)findViewById(R.id.videoView1);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(vv);
Uri video = Uri.parse("/sdcard/sample_mpeg4.mp4");
vv.setMediaController(mediaController);
vv.setVideoURI(video);
vv.start();
}
}