I'm using this code for video streaming, and it's working fine. When a song is finished, it should return back on my home page, like the Mediaplayer.setOnCompletion method.
VideoView videoView = (VideoView) findViewById(R.id.VideoView);
MediaController mc = new MediaController(this);
mc.setAnchorView(videoView);
mc.setMediaPlayer(videoView);
Uri video = Uri.parse(stream_url);
videoView.setMediaController(mc);
videoView.setVideoURI(video);
videoView.start();
How can I do this with MediaController?
Try VideoView.setOnCompletionListener():
Register a callback to be invoked when the end of a media file has
been reached during playback.
Related
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.
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(){
}
I am using following code to play mp4 videos which is stored in sever.... And i am get error like this->
This Video can not be played????
Uri video = Uri.parse("http://129.0.0.....");
MediaController mediaController = null;
mVideoView.setMediaController(mediaController);
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://129.0.0....")));
mVideoView.setVideoURI(video);
mVideoView.setVideoPath("http://129.0.0......");
mVideoView.requestFocus();
mVideoView.start();
This might be helpful to you i have used this in android 2.3.3.
public void videoPlayer(String path, String fileName, boolean autoplay){
//get current window information, and set format, set it up differently, if you need some special effects
getWindow().setFormat(PixelFormat.TRANSLUCENT);
//the VideoView will hold the video
VideoView videoHolder = new VideoView(this);
//MediaController is the ui control howering above the video (just like in the default youtube player).
videoHolder.setMediaController(new MediaController(this));
//assing a video file to the video holder
videoHolder.setVideoURI(Uri.parse(YOUR_SERVER_VIDEOFILE_URL));
//get focus, before playing the video.
videoHolder.requestFocus();
if(autoplay){
videoHolder.start();
}
}
Always pass the mp4,3gp etc video format link in URI.Try this code:
VideoView videoView = (VideoView)this.findViewById(R.id.videoView);
MediaController mc = new MediaController(this);
mc.setAnchorView(videoView);
mc.setMediaPlayer(videoView);
videoView.setMediaController(mc);
videoView.setVideoURI(Uri.parse("http://hermes.sprc.samsung.pl/widget/tmp/testh.3gp"));
videoView.requestFocus();
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();