I'm beginner in android and want to play gif animation in android video view so my gif file in this image show:
and write this code for play that:
VideoView videoView = (VideoView)findViewById(R.id.video_view);
videoView.setVideoPath("raw/newline.gif");
videoView.start();
but when run that app,i get error,can not play this video,why?
Try this code:
Uri uri= Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.newline);
videoView.setVideoURI(uri);
videoView.start();
Your mistake is that you can't just specify a path to resource file. In this case you have to use Uri.
But AFAIK VideoView can't play gif. So check out this and this solutions.
Related
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 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();
I'm using VideoView and MediaController attached to it
i know how to load a video from the raw folder and how to load a url
but i'm unable to load a local file that sits in the Assets folder
i saw some way to do it with a MediaPlayer and SurfaceView, but i'm seeking a way to do so without changing the all activity and layout
Thanks
try using the function getAssets().open("videofile")
Try
Uri uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw....);
videoView.setVideoURI(uri);
I want to play video files in my application which are part of my application.
for that i create 'raw' folder in 'res' and write following code in my activity.
MediaPlayer mp = MediaPlayer.create(VideoPlayer.this,R.raw.jeevrangala);
mp.start();
now i am testing it on emulator, but it does not displaying any thing.
is any one have solution to play video files in raw folder. please let me know.
Initial i was trying to play video files from raw folder. but cant run it. so i use another way to do this
VideoView video=(VideoView) findViewById(R.id.videoview);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(video);
video.setMediaController(mediaController);
//Uri uri = Uri.parse("android.resource://play.vedio/"+R.raw.dobeernotdrugs);
video.setKeepScreenOn(true);
video.setVideoPath("android.resource://one.two/raw/"+resource);
video.start();
video.requestFocus();
resource is file name which you want to play and one.two is package name your path may as like
"android.resource://package_name/raw/file_name"
You can use this code to run video on emulator.. for me it is working
VideoView videoHolder = (VideoView) findViewById(R.id.video_view);
Uri video = Uri.parse("android.resource://" + getPackageName() + "/"
+ R.raw.samplevideo);
videoHolder.setVideoURI(video);
videoHolder.start();
And please turn on your graphics acceleration for the emulator..