Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Play Streaming Audio/Video from a url?

Tags:

I am new in Android. I am using android os 2.2. I am trying to play streaming audio and video from url. I don't know what to do for that. after 3 days og googling i come to know that I have to use mediaPlayer and MediaController classes.

I had use different differend combination of codes found on internet but not succeed.

Can anybody guide me what to do for streaming audio/video playing. What about the UI if we use MediaPlayer or Controller class. is there any thing to related these in xml file of layout.

if not then even please tell me what may be the code for that.

please help me.

like image 537
Kapil Choubisa Avatar asked Nov 01 '10 11:11

Kapil Choubisa


People also ask

How does live streaming audio work?

How does streaming work? Just like other data that's sent over the Internet, audio and video data is broken down into data packets. Each packet contains a small piece of the file, and an audio or video player in the browser on the client device takes the flow of data packets and interprets them as video or audio.

What is streaming live audio and video?

Live streaming is when the streamed video is sent over the Internet in real time, without first being recorded and stored. Today, TV broadcasts, video game streams, and social media video can all be live-streamed.


1 Answers

Hope this helps.

1- Install VLC on your computer (SERVER) and go to Media->Streaming (Ctrl+S)

2- select a file to stream or if you want to stream your webcam or... click on "Capture Device" tab and do the configuration and finally click on "Stream" button.

3- here you should do the streaming server configuration, just go to "Option" tab and past the following command:

sout=#transcode{vcodec=mp4v,vb=400,fps=10,width=176,height=144,acodec=mp4a,ab=32,channels=1,samplerate=22050}:rtp{sdp=rtsp://YOURCOMPUTER_SERVER_IP_ADDR:5544/}**

NOTE: replace YOURCOMPUTER_SERVER_IP_ADDR with your computer IP address or any server which is running VLC...

NOTE: You can see, the video codec is MP4V which is supported by android.

4- go to eclipse and create a new project for media playbak. create a VideoView object and in the OnCreate() function write some code like this:

mVideoView = (VideoView) findViewById(R.id.surface_view);
mVideoView.setVideoPath("rtsp://YOURCOMPUTER_SERVER_IP_ADDR:5544/");
mVideoView.setMediaController(new MediaController(this));

5- run the apk on the device (not simulator, i did not check it) and wait for the playback to be started. please consider the buffering process will take about 10 seconds...

like image 176
Sathish Avatar answered Sep 20 '22 19:09

Sathish