I am trying to load the following free online camera in my app (site: http://www.earthcam.com)
for example, this video.
and I found the video address by IDM (http://video3.earthcam.com/fecnetwork/5187.flv/chunklist_w664887517.m3u8)
I loaded the video in my app with the following code:
String VideoURL = "http://video3.earthcam.com/fecnetwork/5187.flv/chunklist_w664887517.m3u8";
MediaController mediacontroller = new MediaController(MainActivity.this);
mediacontroller.setAnchorView(videoview);
// Get the URL from String VideoURL
Uri video = Uri.parse(VideoURL);
videoview.setMediaController(mediacontroller);
videoview.setVideoURI(video);
videoview.requestFocus();
videoview.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
// Close the progress bar and play the video
public void onPrepared(MediaPlayer mp) {
videoview.start();
}
});
Now I have two problems
How can I play the video in my app with the original url(for example www.earthcam.com/usa/illinois/chicago/field/?cam=fieldmuseum)
How can I display all tools (zoom in, zoom out, volume, stop, pause, like, view, map, etc.)
First question why the video is not playing: the support of a livestream in MediaController is limited. I would suggest you to ExoPlayer https://github.com/google/ExoPlayer
It should handle a livestream playback.
Second question: in order to display all tools that you mentioned you would need an access to the control of the camera either via API or via URL parameters. Then you would need to add this buttons as an overlay on top of the video player and connect buttons to the API calls. However, I don't think that EarthCam provides public API for a camera control.
Related
I am trying to play two video views using the same media controller but it seems impossible to play them and stop them and seek through both at the same time
can someone suggest a solution here is what I am trying :
//2 video views
videoview=(VideoView)findviewbyid(R.id.videowview);
videoviewtwo=(VideoView)findviewbyid(R.id.videowview2);
//the media controller
MediaController mc =new MediaController(this);
//setting uri for both:
videoview.setVideoURI(uri);
videoviewtwo.setVideoURI(uri1);
//setting same media controller object for both
videoview.setMediaController(mc);
videoviewtwo.setMediaController(mc);
//finally start both
videoview.Start();
videoviewtwo.Start();
after this both play well at the first time but when I try to repeat only one starts the other doesnt, thank you for your help.
Edit: I want them both to play at the same time each time I repeat the process .
You need to release and set the mediaplayer to null before you can start the new video. Try to call this when the video has stopped and before you start a new video so you know that the mediaplayer is not busy.
private void releaseMediaPlayer() {
mMediaPlayer.release();
mMediaPlayer = null;
}
So next is to find out when the mediaplayer have stopped playing your video. A hint: MediaPlayer.OnCompletionListener
I'm using VideoPlayer in my app. It play everything fine but when I want to scroll on the media player's bar, usually it gives me the error : Sorry, this video cannot be played. and I have to restart the video to watch it again. All I found is if I stop the video and scroll the bar it will be fine. I just wonder how can I fix this problem ? how can I access to media player's bar. Hens I can pause the video onClick. My code:
MediaController mediaController = new MediaController(
rootView.getContext());
mediaController.setAnchorView(video);
Uri uri = Uri.parse(passVideo.file_link);
video.setMediaController(mediaController);
video.setVideoURI(uri);
video.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer arg0) {
mProgress.setVisibility(View.INVISIBLE);
video.requestFocus();
video.start();
}
});
Many people get this error like you,
Bugs :
Sorry this video is not valid for streaming to this device.
Sorry, this video can not be played.
You can find out at Sorry, this video is not valid for streaming to this device in Http streaming android
Thanks,
I am trying to connect my android application with FTP Server which is broadcasting multiple streams using Dynamic Http Streaming at different bit rates.Flash Messaging Server(FMS) is using H.264 codec to broadcast video in flv format.On client side(Android) I am getting f4m(manifest (xml) file)) having diffrent streams.
I am unable to use the f4m file to fetch video in android from FMS.
String url = "http://d2233avv69kunu.cloudfront.net/hds-live/livepkgr/_definst_/liveevent/livestream.f4m";
Uri uri = Uri.parse(url);
// videoView.setVideoURI(uri);
videoView.setVideoPath(str);
MediaController mc = new MediaController(this);
//VMRuntime.getRuntime().setMinimumHeapSize(40);
mc.setAnchorView(videoView);
videoView.setMediaController(mc);
System.out.println("Max Memory - "+java.lang.Runtime.getRuntime().maxMemory());
videoView.requestFocus();
videoView.setOnPreparedListener(new OnPreparedListener()
{
public void onPrepared(MediaPlayer mp)
{
videoView.start();
}
});
In above code I am trying to run video in Video View component by passing link of f4m file.
Flash encoder convert video into 3 file formats as listed below
.f4m (manifest files) - Bootstrap Info,Metadata, Bitrate, Flash Access license Server location
.f4f (fragment files) - extends the F4V format,MP4 fragment std
.f4x (index files) - binary
Kindly provide solution to play video on different android devices via Http Streaming in android.
Thanks in advance.
1) You have left something out of your code. What is str that you are passing to setVideoPath? (this is somewhat irrelevant, though...)
2) The MediaPlayer (and thereby VideoView) cannot play Flash video at all. It's simply not supported. It definitely won't understand an XML file, either, so passing it the f4m file is pointless.
I've tried to find a simple tutorial which explains how to load a video from a URL into the android media player but unfortunately I couldn't find any!
I have tried several things to try get it working but still no luck.
What is the best way to have a MediaPlayerActivity just load a video from a URL?
Thanks
EDIT:
I have tried the following code as suggested:
VideoView videoView = (VideoView) findViewById(R.id.your_video_view);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
videoView.setMediaController(mediaController);
videoView.setVideoURI(Uri.parse("url-here"));
videoView.start();
It just crashes when I go to this activity.
You can use a VideoView. Here is an example:
VideoView videoView = (VideoView) findViewById(R.id.videoView);
//Use a media controller so that you can scroll the video contents
//and also to pause, start the video.
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
videoView.setMediaController(mediaController);
videoView.setVideoURI(Uri.parse(videoUrl));
videoView.start();
EDIT
You should provide the URI (having a String url variable, where it has the url of the video) with this code Uri.parse(url). And also be sure if the url is appropriate. Also, have you provided the appropriate permissions to your app, as AkashG suggested, (since it uses the internet you will need to add <uses-permission android:name="android.permission.INTERNET" > in your app's Manifest.xml)? Finally you should define your activity MediaPlayerActivity in in your app's Manifest.xml
End of EDIT
You can also use MediaPlayer. The Android developers site has a good tutorial here.
you can load video from url as:
VideoView videoView = (VideoView) findViewById(R.id.view);
MediaController controller = new MediaController(this);
videoView.setVideoPath("url of the video");
videoView.setMediaController(controller);
videoView.start();
Add internet permission in manifest file.
I think you can find useful thinks Here.. about playing video from different sources.
If your using Emulator ,
First, do not use the emulator for testing video playback. Its ability to handle video playback is very limited. Use an actual Android device.
Second, always check LogCat (adb logcat, DDMS, or DDMS perspective in Eclipse) for warnings when you run into multimedia problems. OpenCORE -- the multimedia engine used by Android -- has a tendency to log error-level conditions as warnings.
For example, your video file may not be set up for progressive download, which is required for HTTP streaming. On Linux, you can patch up MP4 videos for progressive download by installing MP4Box and running MP4Box -hint .
Hope this explanation works for you..
Today for one of my app (Android 2.1), I wanted to stream a video from an URL.
As far as I explored Android SDK it's quite good and I loved almost every piece of it.
But now that it comes to video stream I am kind of lost.
For any information you need about Android SDK you have thousands of blogs telling you how to do it. When it comes to video streaming, it's different. Informations is that abundant.
Everyone did it it's way tricking here and there.
Is there any well-know procedure that allows one to stream a video?
Did google think of making it easier for its developers?
If you want to just have the OS play a video using the default player you would use an intent like this:
String videoUrl = "insert url to video here";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(videoUrl));
startActivity(i);
However if you want to create a view yourself and stream video to it, one approach is to create a videoview in your layout and use the mediaplayer to stream video to it. Here's the videoview in xml:
<VideoView android:id="#+id/your_video_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
/>
Then in onCreate in your activity you find the view and start the media player.
VideoView videoView = (VideoView)findViewById(R.id.your_video_view);
MediaController mc = new MediaController(this);
videoView.setMediaController(mc);
String str = "the url to your video";
Uri uri = Uri.parse(str);
videoView.setVideoURI(uri);
videoView.requestFocus();
videoView.start();
Check out the videoview listeners for being notified when the video is done playing or an error occurs (VideoView.setOnCompletionListener, VideoView.setOnErrorListener, etc).