How to play mp4 video on device
Uri uri=Uri.parse(videofile);
VideoView video=(VideoView)findViewById(R.id.videoView1);
video.setVideoURI(uri);
video.start();
if i play video using this code in android e开发者_StackOverflow中文版mulator than it working properly but when i run it on device than it throws error..
will u tell me when i click on specific video that video must play on android videoview or by default play in devices video player
If you play it from SD card use this code
File clip=new File(Environment.getExternalStorageDirectory(),
"haha.mp4");
if (clip.exists()) {
video=(VideoView)findViewById(R.id.video);
video.setVideoPath(clip.getAbsolutePath());
ctlr=new MediaController(this);
ctlr.setMediaPlayer(video);
video.setMediaController(ctlr);
video.requestFocus();
video.start();
}
And if you play video from online use this inside manifest
<uses-permission android:name="android.permission.INTERNET" />
精彩评论