I'm streaming a live radio url directly through Mediaplayer in a service (SDK 8 and above). Some clients are saying that they are hearing some blips and bloops in between the stream. I'm not doing anything different here and just allowing the MediaPlayer to play the audio. Can someone tell me why is this happening?
-Hari
i'm not sure if it's gonna help, but i can tell you the way i play using http streaming for a mp3, for example:
1: the code
mediaPlayer = MediaPlayer.create(this, Uri.parse("http://vprbbc.streamguys.net:80/vprbbc24.mp3"));
mediaPlayer.start();
2: the .pls file
This URL is from BBC just as an example. It was an .pls file that on linux i downloaded with
wget http://foo.bar/file.pls
and then i opened with vim (use your favorite editor ;) and i've seen the real URLs inside this file. Unfortunately not all of the .pls are plain text like that.
tested with android 1.6 and 2.2.
Related
I have a large collection of mp3 files on my server and i'm using android media player for playing them. The problem is for almost all of them getDuration() method returns 0. I uploaded sample mp3 file and put it somewhere on my server. mediaplayer works perfectly fine with that file!!
I can't understand what's the different. My knowledge about audio files is very limited. Can anyone give me a suggestion what to do?
can I somehow modify mp3 files on my server so mediaplayer can read the metadata?
BTW this problem occurs only on Android. My links on google chrome are fine. and google shows the duration of file right from the beginning of playing when only small percentage of file is downloaded.
We finally fixed this issue by replacing our web server. We replaced tomcat with apache and it fixed the issue. I don't exactly know why
I understand that the Android MediaPlayer cannot handle .pls files, but I am trying to create a streaming radio app and the .pls URL is all I have access to. Is there any way to make this work, or am I out of luck?
Just read the .pls files and get all the URLs there. And thats what you have to use since .pls is just a playlist. Once you have all the URLS, you can already use mediaplayer.
Can anyone give me the sample code for parsing and playing .pls file in android?
[playlist]
NumberOfEntries=1
File1=http://stream.radiosai.net:8002/
You need to download the .pls file and read it to find the media file inside since pls is a playlist not a format.
I've been searching for a solution for 2 days about this issue and I've finally found a radio player which you can implement into your code: https://github.com/iammert/RadioPlayerService that plays .pls files from a radio service link (such as: http://stream.radiosai.net:8002/ ).
However, that url on your question should work on the default MediaPlayer but if anyone ever encounters this problem with urls that contain a .pls file, then they should use a radio player that supports the encoding and format.
.
I am developing an app. that will stream the video recorded from camera and stored as mp4 in sdcard...
I know there something called as RTSP which is used for that...
Please tell me where to start . .and is there any library that will do this for me...
I do not understand why you want to stream a local mp4 file, but maybe I misunderstood you problem. RTSP is used for live streaming, but you want to play a local mp4 file.
If you want to capture video and save it as mp4 onto a SD card, you need to use the Android MediaRecorder. Here a link to a simple example.
If you just want to playback a local mp4 file. Have a look at the Android API Demos.
These are part of the Android SDK installation and contain a good example of how to playback local media files.
I am pretty new at streaming video, so please bear with me. :)
I am trying to port an m3u8 stream over from iPhone to Android. Looking in the m3u8 feed, I found some .ts files. From what I can tell, .ts files are, themselves, wrappers that contain the video stream (Elementary Stream).
Is it possible to play a .ts file in Android? (The docs only list 3gp and mp4 as supported formats.)
Is there a way to extract the Elementary Stream and just process the video feed? If that is in 3gp or mp4, I should be ok.
Will Stagefright handle .ts? Is Stagefright even available? I read that there are/were some problems with it.
(As a further caveat, I am not getting much help from my server guys. They are pushing for a Flash player solution, including a proprietary player. They will not provide me with a 3gp or an mp4 feed, but I'm hoping I can find that in the .ts file.)
I'm open to other suggestions. Thanks for your patience with this newbie. :)
There is a standard for that called HTTP Live Streaming. Android 3.0 supports this protocol to some extent which means you can pass the URL of the m3u8 playlist to the MediaPlayer and the player should be able to stream it over HTTP. Stagefright is bundled with Android 3.0.
You can browse its source code here.
Also, this thread might interest you: it summarizes support for HTTP Live Streaming.
Android stagefright in Gingerbread and prior versions does not support playback of .ts (transport stream) or elementary stream. As you have rightly pointed out, it only supports MP4/3GP/MP3 file formats.
You can play .ts video file in android by using NDK based project. Dolphine player is best open source player for android and also supports various formats of video.
You got the .ts link from m3u file. Now you can fetch binary data from .ts file and store this binary data in file, then play this file by using video player.