How to play more than one video from one activity in my android application? I have the following code:
VideoView vd = (VideoView) findViewById(R.id.surface_view);
String movieurl = Environment.getExternalStorageDirectory() + "/content1/bio_brain.mp4";
mc = new MediaController(this);
vd.setMediaController(mc);
vd.setVideoPath(movieurl);
vd.start();
MediaPlayer can play one video at a time. It has an OnCompletionListener callback you can register to get notified when playback stops. Then you can play the second video.
Related
now I'm developing an android Video on Demand or Audio on Demand Player, I notice there's a function in package android.net.Uri, part of my code of play the video or audio is like this:
Play Audio part:
mPlayer = new MediaPlayer();
mPlayer = MediaPlayer.create(this, Uri.parse("http://.../MJ.mp3"));
mPlayer.setLooping(true);
mPlayer.start();
Play Video Part:
VideoView vidView = (VideoView)findViewById(R.id.myVideo);
MediaController vidControl = new MediaController(this);
vidControl.setAnchorView(vidView);
vidView.setMediaController(vidControl);
String vidAddress = "https://.../ABC.mp4";
Uri vidUri = Uri.parse(vidAddress);
vidView.setVideoURI(vidUri);
vidView.start();
I'm wondering does this satisfy the video or audio on demand request? In an other word, when I play the audio or video using the URI function, does it work like Youtube, which downloads just part of the video and plays the video, or download the whole file first then play it?
Hello i have one rtsp live video url, I have't know how to play this live stream live Video url.
i am working on android sample application. Please share your guide with me.
Following code using to play live streaming url.
Don't have any idea, how to get live video streaming. Please suggest me any idea to send to live video stream to server.
below are my sample code.
public class MultimediaActivity extends Activity {
private static final String rtspURL = "rtsp://URL_IP:PORT+video+FileName";
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
VideoView videoView = (VideoView) findViewById(R.id.video);
Log.v("Video", "***Video to Play:: " + RTSP);
MediaController mc = new MediaController(this);
mc.setAnchorView(videoView);
Uri video = Uri.parse(rtspURL);
videoView.setMediaController(mc);
videoView.setVideoURI(video);
videoView.start();
}
}
please suggest me, What should i do..?
Thank you..
Use this code for playing on player
Intent i1 = new Intent (Intent.ACTION_VIEW ,Uri.parse(rtspURL));
startActivity(i1);
and use this code for videoview
VideoView v1 = (VideoView)findViewById(R.id.videoView1);
v1.setVideoPath(rtspURL); //your rtspurl
v1.start()
this work for me ...
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();
I'm trying to play a youtube video using VideoView. It gives me "can not play video" error. What am I doing wrong in the code below. The URL I am using is just regular youtube URL : http://www.youtube.com/watch?v=q7u30Li-oOc
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
setContentView(R.layout.main);
//init components for use
mVideoView = (VideoView) findViewById(R.id.video);
text = (TextView)findViewById(R.id.textView1);
//Get URI data from VideoDemo activity
Bundle uristream = getIntent().getExtras();
videoUri = uristream.getString("urivalue");
//set Texfield to URI string
text.setText(videoUri);
//mVideoView.setVideoPath(videoUri);
//provide VideoView component with file path and play
mVideoView.setVideoURI(Uri.parse(videoUri));
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
mVideoView.start();
}
no need to create separate video view we can play youtube videos directly by using this intent
startActivity(newIntent(Intent.ACTION_VIEW,Uri.parse("video url")));
It is because your phone does not support MP4 videos. Try using video players like daroon which play all sort of videos. First test your application if you able to play videos with .3gp extension. If you cannot, then the problem is with your code.
Uri video = Uri.parse(videoUri);
videoView.setMediaController(mediaController);
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(videoUri)));
videoView.setVideoURI(video);
videoView.setVideoPath(videoUri);
videoView.requestFocus();
videoView.start();
For more info, go through android media format support
I ran the same exact code above , but instead of using a youtube url for the videoUri. I uploaded a video to my site database and set videouri to that URL. IT WORKED!! Apparently VideoView and Youtube streams do not work well together.
mVideoView.setVideoURI(Uri.parse(videoUri));
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
mVideoView.start();
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.