How to find Uri when I have string path of .3gp file? - android

I have path (String path) to my file .3gp on phone and I want to get Uri from that path so I can play in VideoView. I have tried like
video= Uri.fromFile(new File(path)));
videoView.setVideoURI(video);
videoView.start();
but it doesn't work. can someone show me how to find Uri when I have string path ?

I think you can use
videoView.setVideoURI(Uri.parse(path));
Or,
videoView.setVideoPath(path);

Try like this,
VideoView videoView = (VideoView) findViewById(R.id.VideoView);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
// Set video link (mp4 format )
Uri video = Uri.parse("/sdcard/sticky.mp4");
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();

Related

I am trying to play video from google drive using shareable link in video view but unable to play what is the solution for this?

this is my code
mVideoView = (VideoView) findViewById(R.id.videoview);
VideoView videoView = findViewById(R.id.videoview);
// videoPath="https://drive.google.com/open?id=1dXndP-MjQL7USlP0EtaElx67mXujqCSX";
//
Uri uri = Uri.parse(videoPath);
videoView.setVideoURI(uri);
MediaController mediaController = new MediaController(this);
videoView.setMediaController(mediaController);
mediaController.setAnchorView(videoView);
You have to edit the link. Use String functions to edit the text.
Replace open? with uc?authuser=0&.
Add &export=download at URL text ending.
so videoPath= like below:
https://drive.google.com/open?id=1dXndP-MjQL7USlP0EtaElx67mXujqCSX
becomes:
https://drive.google.com/uc?authuser=0&id=1dXndP-MjQL7USlP0EtaElx67mXujqCSX&export=download
Example code:
//# fix path
videoPath = videoPath.replace("open?", "uc?authuser=0&");
videoPath = videoPath + "&export=download";
//# try to play
Uri uri = Uri.parse(videoPath);
videoView.setVideoURI(uri);
MediaController mediaController = new MediaController(this);
videoView.setMediaController(mediaController);
mediaController.setAnchorView(videoView);

does any one know how to play video in video using VideoView

File f = new File("/sdcard/Sample.3gp");
byte[] videoUp=new byte[576600];
videoUp = IOUtils.toByteArray( new FileInputStream(f));
// I want to play video after i convert it into bytes
nothning makes it to play when i convert and put to videoview.
try this:
VideoView videoView = (VideoView) findViewById(R.id.VideoView01);
MediaController mediaController = new MediaController(this);
mediaController.setMediaPlayer(videoView);
videoView.setVideoPath(path);
videoView.setMediaController(mediaController);
videoView.requestFocus();
videoView.start();
mediaController.show();
Instead you can directly play video from sdcard as,
VideoView videoView = (VideoView) findViewById(R.id.videoView);
videoView.setVideoPath("/sdcard/Sample.3gp");
videoView.setMediaController(mediaController);
videoView.requestFocus();
videoView.start();
You can use MediaController if you want to control any player options.

Play youtube video in video player

I want to play a video from youtube in my app. But i dont want to use Youtube application for that. I prefer native videoplayer. I have written the below code for that. But nothing is happening. Only a black screen is displaying.
String link= getIntent().getExtras().get("url").toString();
VideoView videoView = (VideoView) findViewById(R.id.videoPlayer);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
Uri video = Uri.parse(link);
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();
Please help me. Thanks in advance.
just simply do it like that hope it's work:
String link= getIntent().getExtras().getString("url");
VideoView videoView = (VideoView) findViewById(R.id.videoPlayer);
Uri video = Uri.parse(link);
videoView.setVideoURI(video);
videoView.start();

How To Play .avi videos using url in android by programing

How can I play .avi video in android? The video in coming from a url.
Hey you can try the following code to play videos using URL
String link="http://s1133.photobucket.com/albums/m590/Anniebabycupcakez/?action=view& current=1376992942447_242.avi";
VideoView videoView = (VideoView) findViewById(R.id.VideoView);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
Uri video = Uri.parse(link);
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();
Using a VideoView just set the uri:
videoView.setVideoURI(Uri.parse(videoUrl));

How to play mp4 video in android

I want to play mp4 video from server in android.
Video URL
I tried with using video view but there is blank screen appear.
I also tried with Intent.Action view but it show message "Cant play video".
Is there any other way to do this ?
Thanks in advance.
Use Like this:
Uri uri = Uri.parse(URL); //Declare your url here.
VideoView mVideoView = (VideoView)findViewById(R.id.videoview)
mVideoView.setMediaController(new MediaController(this));
mVideoView.setVideoURI(uri);
mVideoView.requestFocus();
mVideoView.start();
Another Method:
String LINK = "type_here_the_link";
VideoView mVideoView = (VideoView) findViewById(R.id.videoview);
MediaController mc = new MediaController(this);
mc.setAnchorView(videoView);
mc.setMediaPlayer(videoView);
Uri video = Uri.parse(LINK);
mVideoView.setMediaController(mc);
mVideoView.setVideoURI(video);
mVideoView.start();

Categories

Resources