How to play MJPEG(live stream) video in Media Player - android

I am working on an application in which I have to play video stream inside my app using Media
Player in android. Its a live streaming video from CCTV, so I don't even know whether we can give Media Player a link to play video or not. Currently I am using a WebView to open the url from my app only but there is one more hurdle that this Video is only accessible from Mozilla FireFox, not from the other browser, so if the user dont have that browser it his/her device then it will not work. Thats why I am opening selection of browsers using the following code :-
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
But it will take the user to the selected browser outside the app,so I just want to know how can I resolve this to make it working.
No matter whether it can be done using Media Player or a webview but I want it within my app only, not outside my app.
Any help would be appreciable.
Thanks

Related

How can I play MP4 video through a direct link in Android video player?

I am making an Android application in which i need to play mp4 video in the android default native video player through a direct downloadable link.
To open the Android video player I am using the following code
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://b.revvolution.com/video/albums-3ry/newshare-der-34972.mp4?download=1"));
intent.setDataAndType(Uri.parse("http://b.revvolution.com/video/albums-3ry/newshare-der-34972.mp4?download=1"), "video/*");
startActivity(intent);
Here the URL is direct downloadable link for the mp4 video.
This code opens the video player but video is not loaded in the video player
I have also used this URL
http://b.revvolution.com/video/albums-3ry/newshare-der-34972.mp4
This URL contains a html5 video player but the video is not loaded in Android video player
But when i use a link of 3GP video like
http://www.androidbegin.com/tutorial/AndroidCommercial.3gp
Then it works.
Please help.
Try the way I did
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("http://www.yourvideo.mp4"), "video/mp4");
Then add the permission : android.permission.WRITE_EXTERNAL_STORAGE , to manifest.
update
First, the video may have issues, as not all videos are safe for streaming.
Second, not all devices may have activities set up to support ACTION_VIEW on video/mp4 files that are streamed. You should use PackageManager and queryIntentActivities() to confirm whether the startActivity() call will find a match, or handle the ActivityNotFoundException that you get.
You need to check the Android Video Encoding Recommandations . Make sure that your video is encoded with the supported code, and your video respects the resolutions.After the video were properly encoded the streamming worked.
Also if you didn't noticed yet, usually the emulator does not play them, and you'll have to test on a real device.

Android -- Cannot get the videos streaming from my server

I am using the following code to stream the videos from my server on android phone:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(videoUrl)); // When I hit this URL in web browser on my PC, it works
startActivity(i);
When I run the code, it asks me to select a player. When I select a player, that player opens up and then nothing happens. I've even tried waiting for minutes, but the video never starts.
My question is, is it really as simple to just put the video on my webserver and on android run the above code to get that video streaming?
Do I need to make any changes on my server? Can anyone please help me with this? I cannot figure out if the problem is with my sever or client side.
It was the problem of VLC player that I was using on my Android Phone for testing. I downloaded the MX Player and tried it with that. Everything is working fine now :-)
That means not every video player on Google Play is mature enough to take a URL and start streaming the video. For that you need a good video player that supports this feature.

Uploading video from phone

I have a website where the user of my application can upload a video from the Android Gallery. I want to make it so that when the user opens the file chooser it has an option to record a video and upload it from the Androids stock camera. Is this possible or would I have to create an application that would handle the video recording and post the video to the file chooser? Either way it would be nice if someone could point me in the right direction.
I will suggest you to write your application, it will me be more customize and can be handles completely on your way . This link will help you related media recording Media Recorder and for uploading to server you can look in to this Uploading video

you tube video not playing

I am new to android. I am trying play a youtube video whose path is present in an html file.. But when I do that I get black screen and upon tapping that a link will be displayed.. But I want the video to be displayed in my webview and on touching that video should be played..
I am using the following code..
webView = (WebView)findViewById(R.id.webView1);
WebSettings websets = webView.getSettings();
websets.setJavaScriptEnabled(true);
webView.loadUrl("file:///android_asset/youtubes.html");
any help on this ?
Thanks,
Keerthi
YouTube usually requires flash. Are your links pointing to desktop version of YouTube? Do this links play in your browser in Android (not opening the YouTube app)?
Also take a look at m.youtube.com - this links are created to run on mobile devices by opening external player.
If you are running it on an emulator, then videos will not play from the youtube as you require flash. But if you are running it on a phone, then check if you added the methods properly or not. Also try using the VideoView class which takes the video source from your SD card. If it works, then it might be some problem with your code or if it doesnt works try installing any external player

what is the default media player in android?How we can make url to play video in default player of android?

I understand that all Android phones will have the WebKit browser Application. Is there a default Media Player? How we can make while clicking in url to play video in default player of android?is there any way to embedded code to play in android device default player?
Android Application SDK has MediaPlayer class for multimedia playback use case. You can directly use this class or can use VdeoView class.
Can refer to VideoView usage here.
Shash
just a note. If it is a Youtube video, the browser as it is already automatically detects that and offers the user to open the video in Youtube, or other video player the user might have installed.

Categories

Resources