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.
Related
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 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));
Here is my code. In this if I launch the intent with video url it play's while it doesn't play's in videoview is there any way to get it working in VideoView
VideoView mVideoView = new VideoView(this);
String videoURL = "video_url";
mVideoView.setMediaController(new MediaController(this));
mVideoView.setVideoURI(Uri.parse(videoURL));
setContentView(mVideoView);
while this native player plays video
Intent theIntent = new Intent();
theIntent.setDataAndType(Uri.parse(videoURL), "video/*");
I tested this on device also
Try below way
VideoView videoView = (VideoView) findViewById(R.id.VideoView);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
// Set video link (mp4 format )
Uri video = Uri.parse("mp4 video link");
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();
Refer this link
https://stackoverflow.com/a/6410421/1441666
And also check supported formats Android Supported Media Formats
https://stackoverflow.com/a/8714189/1441666
i think this might be helpfull.
VideoView view = (VideoView) findViewById(R.id.xxxx);
MediaController mc = new MediaController(this);
mc.setMediaPlayer(view);
view.setMediaController(mc);
try{
view.setVideoURI(Uri.parse(file_path));
} catch(){
}
view.requestFocus();
try{
view.start();
}catch(){
}
How can I play videos from URL in android?. without new Intent?. is available?
Thanks
try this
String url="your video url";
VideoView videoView = new VideoView(this);
videoView.setVideoURI(Uri.parse(url));
setContentView(videoView);
videoView.setMediaController(new MediaController(this));
hope help
Try this code...It should work fine.
VideoView videoView = (VideoView) findViewById(R.id.video_view);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
String link = "http://www.youtube.com/watch?v=lEbxLDuecHU&playnext=1&list=PL040F3034C69B1674";
Uri videoLink = Uri.parse(link);
videoView.setMediaController(mediaController);
videoView.setVideoURI(videoLink);
videoView.start();
How does live video streaming work in Android?
Although I havent tried this but according to web it works
VideoView videoView = (VideoView) findViewById(R.id.surface_view);
MediaController mc = new MediaController(this);
mc.setAnchorView(videoView);
mc.setMediaPlayer(videoView);
Uri video = Uri.parse(URL);
videoView.setMediaController(mc);
videoView.setVideoURI(video);
videoView.start();