开发者

how to playback video from internal storage(my app) with videoView

开发者 https://www.devze.com 2023-03-22 07:54 出处:网络
Im trying to play video from internal storage, but videoview cant play it. Is there a way to do this and not by temporarily copying to sdcard and playing it?

Im trying to play video from internal storage, but videoview cant play it. Is there a way to do this and not by temporarily copying to sdcard and playing it? The video was recorded开发者_运维知识库 with mediarecorder.


Use this code in your activity

 VideoView videoView = (VideoView) findViewById(R.id.video_view);
 MediaController mediaController = new MediaController(this);
 mediaController.setAnchorView(videoView);
 videoView.setMediaController(mediaController);
 videoView.setVideoPath(getFilesDir().getAbsolutePath()+"/file_name.mp4");
 ideoView.start();

The file_name.mp4 must be created with Context.MODE_WORLD_READABLE

Holp this helps

0

精彩评论

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