I have added a raw file to my Res file but in java its not recognising the raw file or the mp4 file. Please see screen shot with highlights below
If you want to reproduce the video, see the code below.
VideoView videoView = (VideoView) findViewById(R.id.videoView_video);
Uri path = Uri.parse("android.resource://" + getPackageName() + "/"+ R.raw.starwars);
videoView.setVideoURI(path);
videoView.start();
Remove the extension (.mp4)
Related
Do I have to change the file type? Because when I watch youtube vids I noticed that all the icons have a question mark, while mine has like a text file.
you should try this and check more here about VideoView
VideoView vidview = (VideoView)findViewById(R.id.videoView);
String path = "android.resource://" + getPackageName() + "/" + R.raw.video_file;
vidview.setVideoURI(Uri.parse(path));
vidview.start();
use this line in the java code under declaration
video.setVideoURI(Uri.parse(path));
I have checked other questions, and applied the solution available in them, but still it is not working.
I have placed a video in my raw folder. I am getting the video by using following method
String path = "android.resource://" + getPackageName() + "/"+ R.raw.splash_video;
videoView= (VideoView) findViewById(R.id.splash_videoView);
Uri uri= Uri.parse(path);
videoView.setVideoURI(uri);
videoView.start();
The video is in mp4 format, When i run my program, it displays me Can't play the video message.
When i debug the code, i found out that, it changes the path value to this:
path= android.resource:///2131099757
If i change the path to Some URL, it successfully plays the video.
String path= "www.abc.com/someVideo.mp4"
Kindly guide me how to play mp4 video from raw
Try with this URL.
String uriPath = "android.resource://"+getPackageName()+"/raw/myvideo";
Where myvideo is your video file name.
Hi i want to play a video file but after showing video it is showing error that can't play video file i am using Video view and path of video is
Uri uri=Uri.parse(Environment.getRootDirectory().getPath()+"/Phone storage/video.mp4");
Can some help me how to play video file that is store on my phone
You should use Uri.fromFile instead of Uri.parse
Create "raw" folder in "res", copy your video file to raw folder, in your code you should to do that :
String UrlPath = "android.resource://" + getPackageName() + "/"
+ R.raw.your_video_name;
Uri video_uri = Uri.parse(UrlPath);
video.setVideoURI(video_uri);
video.setMediaController(new MediaController(this));
video.requestFocus();
video.start();
Try out this way:
Uri.parse(Environment.getExternalStorageDirectory().getAbsolutePath()+File.separator+"Phone storage"+File.separator+"video.mp4");
I'm trying to access the video file under assets folder. But When I run this, it shows error message(can't play this video file). I doubt something wrong with path.
videoView = (VideoView)findViewById(R.id.VideoView);
videoView.setVideoPath("file:///android_asset/testdoc.mp4");
videoView.start();
Use raw folder rather than asset:
String videoPath = android.resource://+ getPackageName() +/raw/testdoc";
Uri uri = Uri.parse(videoPath);
video.setVideoURI(uri);
I just wanted to run a predefined video file when a button is clicked. I have added this video file into res/raw folder in myVideApp project. Now I need to pass this path to videoView.setVideoPath() in order to play the video.
How can I access the stored video file's actual path in android. Note: I don't want to open the file. just want the actual location of the file to pass to video view.
I tried "path = this.getResources().getString(R.raw.bbc);" but its not working since it gives the path relative to the current project. but videoview needs absolute path.
Thank you,
Regards,
Robo.
Following Snippet will help you.
getWindow().setFormat(PixelFormat.TRANSLUCENT);
videoView = new VideoView(this);
videoView.setMediaController(new MediaController(this));
videoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() +"/" + R.raw.bbc); //Don't put extension
videoView.requestFocus();
setContentView(videoView);
videoView.start();
Following are steps to access video file and to play video
Get Video Control
create media controller
Get Video path from local resorce
Set media controller to video
set path of video in video control
Set Focus
Start Video
.
VideoView videoView = (VideoView)findViewById(R.id.videoViewGuide);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
Uri uri = Uri.parse("android.resource:// " + getPackageName() + "/" + R.raw.Guide_Video_01);
videoView.setMediaController(mediaController);
videoView.setVideoURI(uri);
videoView.requestFocus();
videoView.start();