live audio streaming in android - android

I am facing problem to play a audio url using MediaPlayer as well as native Android audio player.
Here is my url
http://live.politiafm.com:8500/politiafm.mp3
Here is my code
Using native audio player
Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(STREAM_URL), "audio/*");
StartActivity(intent);
Using Media Player
MediaPlayer mp = new MediaPlayer();
mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
mp.create(Landing.this, Uri.parse(STREAM_URL));
mp.prepareAsync();
mp.start();
In both the cases audio is not playing. Can some body help me out from this trouble.
Thanks & Regards

I guess it is to late a reply but in case if you are still facing the same problem,
you need to enable mime type for your server based on the type of the server. The MIME types are something you can learn from here how to enable them for Tomcat Server, IIS Server or Apache, whichever your mp3 file is hosted on : http://www.developershome.com/wap/wapServerSetup/tutorial.asp?page=settingUpMIME
Thanks

try changing
mp.prepare();
not
mp.prepareAsyunc();

Related

Streaming m3u8 HLS Audio on Android

i've found problems trying to reproduce m3u8 HLS audio streaming on Android. Right now i can reproduce video in m3u8 HLS link with:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(Uri.parse(contentURL),"video/mp4");
startActivityForResult(i,0)
I've already tried this method:
number 1:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(Uri.parse(contentURL),"video/mp4");
startActivityForResult(i,0)
number 2:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(Uri.parse(contentURL),"audio/mp3");
startActivityForResult(i,0)
number 3:
MediaPlayer mediaPlayer = MediaPlayer.create(this, Uri.parse("http:\\testexample.m3u8"));
mediaPlayer.start();
In case 3 the error on log like "mediaserver Died", in case 1 and 2 simply the phone gallery said "can't reproduce video" or "can't reproduce this kind of file".
Last but not the least, if i send the http m3u8 link with an email at a Nexus 4 with Android 4.3, it open the link with chrome, then ask to open phone galleryplayer, and reproduce it. The same thing done with da SII with cyanogenmod and android 4.2.1 said, as before, "cannot reproduce video".
Put your code In try-catch block.
Set onPreparedListenet() and prepareAsync(), then on the onPrepared() callback start playback.

Hot to get live streaming data in android

I am trying to make an app which gets livestreaming camera videos. I can stream my webcam from my laptop on the ip (for example ip:176.33.226.53:8070), by using the 1AVStreaming program but I can't reach the streaming video in my code.
Media Player can directly work with the url itself.
Look for something like
Uri myUri = Uri.parse("http://your/video/file/path");
MediaPlayer player = new MediaPlayer();
player.setDataSource(context, myUri);
player.prepare();
Use MediaPlayer.OnPreparedListener to show controls or start the video
Their are various examples available. Just Google It

Android MediaPlayer error -1004 (ERROR_IO)

My application plays audio stream
Here the code:
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setDataSource(url);
mediaPlayer.prepare();
mediaPlayer.start();
url is local file (127.0.0.1)
I use my own HttpServer which runs on the same phone.
After call to
mediaPlayer.prepare();
I get the error:
error (1, -1004) which is ERROR_IO
Any idea what is this error?
Thanks, Costa.
the problem is php5 which sends a 500 http header if your server does not send the correct headers
Android MediaPlayer error -1004 (ERROR_IO)
You can use mediaPlayer.prepareAsync(), but not mediaPlayer.prepare().
Please try it...
The problem was with HTTP server.
I used alternative server:
http://www.prasannatech.net/2008/10/simple-http-server-java.html
And it works great!
I change my video from mp4 to 3gp.
Its work for me.

PVMFErrContentInvalidForProgressivePlayback MediaPlayer IOException: Prepare failed.: status=0xC8

I want to play video from a URL via HTTP. I read Media Tutorial and other stackoverflow questions. Here is my code:
String url = "http://..../myVideo.mp4"
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setDataSource(url);
mediaPlayer.prepare();
mediaPlayer.start();
mediaPlayer.prepare() is throwing IOException: Prepare failed. For the test purpose I record a video using my mobile phone and then I put the mp4 file to server.
I missed this line from stack trace:
08-17 14:36:58.005: ERROR/PlayerDriver(1943): Command PLAYER_INIT completed with an error
or info PVMFErrContentInvalidForProgressivePlayback
The problem is: my video is not capable of progressive download.
The only solution I figured out is using MP4Box which can be downloaded from here.
To make video ready for android I just run MP4Box.exe -hint myVideo.mp4.

Playing audio file into the call android

Say I make a call to someone with my android phone.
Is it possible to play some audio file into the call?
I just tried like this
if(state==TelephonyManager.CALL_STATE_OFFHOOK){
AudioManager am = (AudioManager) pccontext.getSystemService(Context.AUDIO_SERVICE);
am.setMode(AudioManager.MODE_NORMAL);
am.setSpeakerphoneOn(true);
MediaPlayer mp = MediaPlayer.create(pccontext, R.raw.beep);
mp.start();
}
But its not working in MODE_NORMAL. When I tried with MODE_IN_CALL phone is playing the audio but caller on the other side is not able to listen the audio played by the receiver phone.
Unfortunately, it is not possible, it is an Android security limitation.

Categories

Resources