开发者

How to play mp4 video on device

开发者 https://www.devze.com 2023-03-19 17:19 出处:网络
Uri uri=Uri.parse(videofile); VideoView video=(VideoView)findViewById(R.id.videoView1); video.setVideoURI(uri);
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" />
0

精彩评论

暂无评论...
验证码 换一张
取 消