My question is about media player live streaming from the url in my application?
I'm trying to play live stream mp3 audio by media player.
The problem is that when i am using default URL as given in this link , then it works fine. But i changed the following mp3 link ,
then after playing 1 seconds it taking buffering and after completion its play the song, but i need that it plays the song with the buffering as well.
please help.
Thanks in advance.
It is not easy task to accomplish.
You can use this link https://code.google.com/p/mp3tunes/source/browse/
as reference app to develop your own progressive mediaplayer app.
From the above link you will get the whole architecture for your app.Song downloading and playing is happens at the same time.The architecture developed in the reference app is more robust and reusable.
Specially look at following classes
NanoHTTD.java
HttpServer.java
PlaybackService.java
PlaybackQueue.java
TrackDownloader.java
Thank You.
Related
There is a live streaming video in one of my app which is from one of the websites http://shirdisaiholidays.com/live-dharsan-3/.
I used activity starter with URI as rtsp://cam.live-s.cdn.bitgravity.com/cdn-live2-b1/_definst_/cam/live/secure/feed022/playlist.m3u8?e=0&h=ba7f5c5f6bf8a02d29f909dfa8d0c075.
It worked for some time but now it has stopped altogether. Someone said I can use video player or player with the url as source which I have also used without any success. It shows an error 702. Other apps using the same live streaming are working fine.
I have made a small app for playing live stream.It is working good on other devices but on Samsung Galaxy S3 can not control the media player. I am using media player using the following code
sdrPlayer = new MediaPlayer();
sdrPlayer.setOnErrorListener(video.this);
sdrPlayer.setOnCompletionListener(video.this);
sdrPlayer.setOnPreparedListener(video.this);
sdrPlayer.setOnBufferingUpdateListener(video.this);
sdrPlayer.setDataSource(video.this, Uri.parse(url));
sdrPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
sdrPlayer.setScreenOnWhilePlaying(true);
sdrPlayer.prepareAsync();
but media player is throwing the issue media player error (1, -110) but I do not know the meaning of this error and also there is no proper documentation. I found this documentation but I can not get the error and also media player starts playing a bit late after calling start function in on prepare listener.I can not control the pause and play of the stream.
Any kind of help will be highly appreciable.
It is not enough of information. I think adding more code, may be even full file, would help. As per my experience, S3 is less troublesome device on playing rtsp streams, I have created rtsp player too. You might have done something wrong. Let's also ask what the stream you are trying to play, hls, anything else?
You could also do the following:
try to play the stream with some desktop player: quicktime, mplayer.
Do they play it right?
try to validate the stream with one of those rtsp streams validators, do they find it ok?
I want to stream an audio mp3 file and then play it through android media player plus I also want to cache this file, so that mediaplayer don't have to stream for recently played tracks.
I have tried using prepareAsync method but it doesn't give me access to buffer content, so I have decided to stream the audio file myself and then pass it to the media player for playing. I have achieved this by following this article here but this approach has a problem i.e. while transferring the file to media player it goes into error mode which causes my player to behave inconsistently.
When media player enters its error mode it doesn't come out of it automatically so I am forced to create a new media player and then re-provide it the downloaded file, this workaround causes the user to experience an undesired pause in the song playing.
So, does any one have improved an version of code given in above link? or do they know a better solution to this problem or is there is actually a library for streaming an audio file in android?
Thanks
The link you provided looks like a less than ideal solution (not to mention outdated). What you probably want is a local proxy server that gives you access to byte data before the MediaPlayer gets it. See my answer here for a little more explanation.
We are trying to develop an app for Android where you can play a live streaming URL. I tried several approaches using the MediaPlayer and StreamPlayer... but no luck with the URL playing.
I can of cause play a static MP4 or MP3 file using the URL (hosted on a server) but when I try to play a stream URL it doesn't play or give an error.
Any thoughts?
Mp3 stream works well on Mediaplayer from Android 2.2 and above. If you want to play the Content below 2.2 then its better to use local proxy server implementation. check Npr . Which uses the same approach.
If you want to play wma audio you should convert that into PCM and play it. check aacplayer. In aacplayer project he gets wma content from mms:// stream and plays it . You can edit that to play only wma content. But i haven't tried playing any wmv videos.
I have created one songs album app. In this app, i have to play the songs by using URLs. These URLs gave me 2 types of songs.The first one is on-demand songs, which are our regular songs limited to 5 or 6 minutes. I dont have any problems to play/stop these songs with MediaPlayer object. The second one is live streaming, which is nothing but shout casting.With this shout-casting URLs, the MediaPlayer object is not working properly that means after playing say some 5 seconds of song the mediaplyer stops playing. I dont know what is the problem with live streaming data. if anyone knows about this, please guide me to rock the Mediaplayer.
Thanks
Venu
To play live streaming we need to set mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
It works for me a lot.