开发者

Android 2.2: code for playing a video from sd card / streaming from web

开发者 https://www.devze.com 2023-02-02 01:36 出处:网络
I would like to know how to play a video file in my app. Either from the SD-card or from a source like YouTube for example. The video should play in fullscreen mode, and when the video is complete, i

I would like to know how to play a video file in my app. Either from the SD-card or from a source like YouTube for example. The video should play in fullscreen mode, and when the video is complete, i want to return to my app. Is there any way to accomplish this?开发者_开发知识库

Thanks!


You can use VideoView inside a LinearLayout

Snippet as follows

PS> I havent included all the userinput and error

VideoView videoView = (VideoView) findViewById(R.id.VideoView01);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
//URI either from net or local
Uri video = Uri.parse("http://yourfavouriteurl/abc.3gp");
Uri video = Uri.parse("android.resource://full.package.name/" + R.raw.yourvideo);
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();
0

精彩评论

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