Hello Friends,
Today i am sharing post regarding live streaming from server to android application.
Note : There are so many different way to do live streaming in android application but in android only 3gp and mp 4 are playing smoothly or it may have exception for large resolution video also. we have to implement different approach for rest live streaming.
permission: <uses-permission android:name="android.permission.INTERNET" />
More Ref Link:
Today i am sharing post regarding live streaming from server to android application.
Note : There are so many different way to do live streaming in android application but in android only 3gp and mp 4 are playing smoothly or it may have exception for large resolution video also. we have to implement different approach for rest live streaming.
import
android.app.Activity;
import
android.app.ProgressDialog;
import
android.graphics.PixelFormat;
import
android.media.MediaPlayer;
import
android.media.MediaPlayer.OnPreparedListener;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import
android.widget.VideoView;
public class MainActivity extends Activity
{
private static ProgressDialog progressDialog;
String
videourl="You video url"; //It should be 3gp or mp4
VideoView
videoView ;
@Override
protected void onCreate(Bundle
savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
videoView = (VideoView)
findViewById(R.id.video_View);
progressDialog = ProgressDialog.show(MainActivity.this, "", "Buffering
video...",true);
progressDialog.setCancelable(false);
PlayVideo();
}
private void PlayVideo()
{
try
{
getWindow().setFormat(PixelFormat.TRANSLUCENT);
MediaController
mediaController = new MediaController(MainActivity.this);
mediaController.setAnchorView(videoView);
Uri
video = Uri.parse(videourl);
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.requestFocus();
videoView.setOnPreparedListener(new OnPreparedListener()
{
public void
onPrepared(MediaPlayer mp)
{
progressDialog.dismiss();
videoView.start();
}
});
}
catch(Exception e)
{
progressDialog.dismiss();
System.out.println("Video Play
Error :"+e.toString());
finish();
}
}
}
XML Layout:
<?xml version="1.0"
encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center" >
<VideoView
android:id="@+id/video_View"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
>
</VideoView>
</RelativeLayout>
</LinearLayout>
permission: <uses-permission android:name="android.permission.INTERNET" />
More Ref Link:
I
will be happy if you will provide your feedback or follow this blog. Any suggestion
and help will be appreciated.
Thank
you :)
This comment has been removed by the author.
ReplyDeleteHi,
ReplyDeleteit is not show progressDialog........
are you getting any error?
ReplyDeletehello this is ram,we are using rest full web server in my android application.
Deleteplease help me how to upload video from mobile application to server.connect with me ram.mohan375@gmail.com
hello this is ram,we are using rest full web server in my android application.
Deleteplease help me how to upload video from mobile application to server.connect with me ram.mohan375@gmail.com
Please see and implement carefully, it will work nice.
ReplyDeleteits not showing nythng..shl i add somthing i mean ny class or nythng..
ReplyDeleteits not showing nythng..
ReplyDeletei have change some code now you can try it, is it working on not, and make sure for internet permission on AndroidManifest.xml file.
ReplyDeleteIts working fine for me. Thanks
ReplyDeleteHi Hasmuk,.
ReplyDeletePlease tell How to play RTMP or HLS streaming video in ur code,..I tried ur code but i cant play RTMP,.
what am getting is "Sorry, This video cant be played"
please tell me what i have to do
Thank you.
Hello,
DeletePlease try following ways.
1. Device:
Replace Http with Http live
eg.path=path.replace("http","httplive");
For:
2. Tablets:
For tab Http is fine
Note: Set android:hardwareAccelerated="true" in android AndroidManifest.xml file.
hai hasmukh can u pls tell wer i want to insert path=path.replace("http","httplive")
Deleteor is ter anything to add in tat.
and in manifest file under which tag, android:hardwareAccelerated="true" this should be placed...
kindly reply me fast
Please Contact me @
ReplyDeletevsamurali.rick@gmail.com
please am awaits to hear u,.
Its not working showing dialog that "this video can not play". I tried for "http://www.nasa.gov/multimedia/nasatv/NTV-Public-IPS.m3u8"
ReplyDeleteHello,
Delete.m3u8 url is directly not working in above code that code is used only if you have .3gp or .mp4 files.
you have apply following way:
Please try following ways.
1. Device:
Replace Http with Http live
eg.path=path.replace("http","httplive");
For:
2. Tablets:
For tab Http is fine
Note: Set android:hardwareAccelerated="true" in android AndroidManifest.xml file.
hi Hasmukh,.
DeleteAm using vitamio player to play my m3u8 stream its working perfect,..but after 20 min its got freeze on Android box, but ion emulator its working fine,.
pls tel wat might b the problem,.if u need code for the clear idea i'll send u pls give me ur contact.
thank you,.
Is there any other ways to play m3u8 stream in android,.pls tell me,.its urgent
Deletethanks,
murali.
is it works on mjpeg webcam format ??thanks
ReplyDeletethanks ............
ReplyDeletebut after few secs the screen slipt into two parts.
ReplyDeletedo u have any idea?
Hello,
ReplyDeleteSound is played but no video. Please advice.
I'm trying to play a video saved from Ustream, example this http://www.ustream.tv/recorded/15480382, but the on screen appears "Can't Play this video", any suggestions?
ReplyDeleteFirst check video formate and Video resolution.
DeleteIt depend on video format in android phone, generally in android 3gp formate is good to play video, if device like s3, s4 then HD video play other wise it will not play. and need convert in .3gp format.
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteI was trying to add .mp4 video from url but not showing video although there was no error, no exception, audio was 'ok' but not displaying video :( plxx help
ReplyDeleteif you are using android device <=2.3 Os then it play, if you are using device >4.0 then you need to give one permission in android manifest file.
Deleteandroid:hardwareAccelerated="true"
Hi,
DeleteAny body can help me? i have use above source code for live straming video. every thing is right but i want to know when i stop the video can i get size of played video which i have seen. is it possible get size of video from live streaming?? how much mb/kb video i have seen.
if anyone know please help me. source code mail me at majid.khuhro@gmail.com
I trying to run live streaming of ODIYA TV http://www.odishatv.in/TV/live_tv.php
ReplyDeletebut it is not working ..
please help me on this.
Showing Cant Play this video ..
I trying to run live streaming of ODIYA TV http://www.odishatv.in/TV/live_tv.php
ReplyDeletebut it is not working ..
please help me on this.
Showing Cant Play this video ..
I want to play Live TV channel like Colors, Aaj tak, Sony, Max etc
ReplyDeletein my android app.
Please can you send me the code, how to play live tv ?
at manoj.cs.iu@gmail.com
Plz help meas soon as possible
Hello Manoj,
ReplyDeleteyes it possible but it depend on live streaming Url, it you can play on Video view then you can used Html 5 for playing video.
Hello I want to play video from url http://www.universitiesdata.com/?c=1 anyone help please
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteHi,
ReplyDeletei want to play live tv channel like "http://livetvchannelsfree.com/aajtak.html"
kindly request you to check how to play this url in above project.
How to play this url in videoview .
i want to create a app like view my ip camera in the my own app pls help to create and if anyone have the code send to me prabhu2420@gmail.com please thanks.
ReplyDeleteHi,
ReplyDeleteAny body can help me? i have use above source code for live straming video. every thing is right but i want to know when i stop the video can i get size of played video which i have seen. is it possible get size of video from live streaming?? how much mb/kb video i have seen.
if anyone know please help me. source code mail me at majid.khuhro@gmail.com
Hi,
ReplyDeleteHow to play live video streams from urls like this, rtmp://202.75.154.34:1935/live/livestream
Hi
ReplyDeleteCan any one tell me the example link for live video
http://www.yupptv.com/sakshitv.html
its not working.
Hello Hasmukh, I would like to ask you how to develop an application for video sharing between two androids using WIFI-Direct in real time, thank you.
ReplyDeleteHello Ibrahim,
DeleteYes that you can do, there is a sample code in android sdk samplecode folder.
androidSDK\samples\android-19\connectivity\NetworkConnect
here there you can share file between android phone using wifi.
Thanks
hello i read ibrahim comment and i like the idea but if i want to do the same thing as following ( Live video streaming between two androids using Peer to peer connection (wifi-direct) where one of the android is going to broadcast the video over the internet ( HTTP access )
DeleteHi Hasmukh,
ReplyDeleteI'm developing an app for traffic updates in a video format .In the app the user can monitor a road for how the traffic density is .we need to send traffic update as a video through cameras which monitor the live traffic and at the same time the user can view it.
This comment has been removed by the author.
ReplyDeleteHi, This code working fine for me if i change following statment
ReplyDeleteString videourl=""; to String videourl="http://www.pocketjourney.com/downloads/pj/video/famous.3gp";
Thank you
hi, very useful tutorial for beginners. But I am trying to use url as http://zingo.tv/watch.php?id=36 , and its showing dialog as cant play this video. Can you please help me out. I completely followed your code, only a String variable is changed to that url.
ReplyDeleteThank you
Hi,
ReplyDeleteCan anyone please tell me how to download the project/source code for this example?
Thanks !!
how to play the axis network camera live video like(http://wmccpinetop.axiscam.net/view/view.shtml?id=153155&imagepath=/mjpg/video.mjpg) in android application any one can you help me??
ReplyDeleteLive streaming is the latest fad on social media so make sure to get live with your audience from time to
ReplyDeletetime.
Live streaming would give you a more intimate space with your viewers and encourage them to interact with
you more often. It would allow more personal interaction with your audience in real time.
You can also share your live videos later, so that those who have missed out the live streaming can view
them again. A tour of your business, a demonstration of your products or an interview with the creators
are some of the possible content which can be created with a live video.
Make sure to make the most out of the apps which allows you to go live directly from the blog.
Live streaming is the latest fad on social media so make sure to get live with your audience from time to time.
ReplyDeleteLive streaming would give you a more intimate space with your viewers and encourage them to interact with you more often. It would allow more personal interaction with your audience in real time.
You can also share your live videos later, so that those who have missed out the live streaming can view them again. A tour of your business, a demonstration of your products or an interview with the creators are some of the possible content which can be created with a live video.
Make sure to make the most out of the apps which allows you to go live directly from the blog.
Live streaming is the latest fad on social media so make sure to get live with your audience from time to time.
ReplyDeleteLive streaming would give you a more intimate space with your viewers and encourage them to interact with you more often. It would allow more personal interaction with your audience in real time.
You can also share your live videos later, so that those who have missed out the live streaming can view them again. A tour of your business, a demonstration of your products or an interview with the creators are some of the possible content which can be created with a live video.
Make sure to make the most out of the apps which allows you to go live directly from the blog.
Live streaming is the latest fad on social media so make sure to get live with your audience from time to time.
ReplyDeleteLive streaming would give you a more intimate space with your viewers and encourage them to interact with you more often. It would allow more personal interaction with your audience in real time.
You can also share your live videos later, so that those who have missed out the live streaming can view them again. A tour of your business, a demonstration of your products or an interview with the creators are some of the possible content which can be created with a live video.
Make sure to make the most out of the apps which allows you to go live directly from the blog.
Live streaming is the latest fad on social media so make sure to get live with your audience from time to time.
ReplyDeleteLive streaming would give you a more intimate space with your viewers and encourage them to interact with you more often. It would allow more personal interaction with your audience in real time.
You can also share your live videos later, so that those who have missed out the live streaming can view them again. A tour of your business, a demonstration of your products or an interview with the creators are some of the possible content which can be created with a live video.
Make sure to make the most out of the apps which allows you to go live directly from the blog.
Legend Online Benzeri Oyunlar
ReplyDeleteMafia 2 Benzeri Oyunlar
Simcity Benzeri Oyunlar
Papers Please Benzeri Oyunlar
Phasmophobia Benzeri Oyunlar
6KZ