URl not played in android MediaPlayer - android

I'm working media palyer app, in this i need to stream audio from URL. In my case some URL's are not streamed in some devices (Eg. Samsung Note III), after a long time i got this error message in onError() method.
E/MediaPlayer(24445): error (1, -1004)
I used the following code to pay url.
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setDataSource(songPreViewUrl);
mediaPlayer.setOnPreparedListener(BackgroundAudioService.this);
mediaPlayer.setOnCompletionListener(BackgroundAudioService.this);
mediaPlayer.setOnBufferingUpdateListener(BackgroundAudioService.this);
mediaPlayer.prepareAsync();
Can any one please share the suggestion, why the urls are not streams in Samsung devices.

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.

MediaPlayer stops streaming audio playback

I use MediaPlayer to play mp3 stream via http. On some specific devices it doesn't reach the end of the stream too often. Just stops. It occurs only on 2.3.x, can not catch this problem on Jelly Bean. The only strange lines in logcat:
02-04 17:34:14.379: ERROR/HTTPStream(95): recv failed, server is gone, total received: 54683 bytes
02-04 17:34:14.379: ERROR/HTTPStream(95): recv failed, errno = 9 (Bad file number)
02-04 17:34:14.379: ERROR/NuCachedSource2(95): source returned error -1004
OnCompletionListener is called (too early)
Seems like it downloads only 5MB of the stream and doesn't try do download more.
Happens mostly on Samsung Galaxy Ace devices.
you can try this
android media player connecting status with audio streaming link(ie 2%,4%...100% then online radio start to play) in android
this perfectly play streaming mp3 via http.
or just go http://coderfriend.blogspot.com/ blog.

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

WAV plays from file, does not play directly from URL

I have a URL that returns a 8-bit PCM, mono, 8 kHz WAV sound. When I try to play that URL via Android's MediaPlayer class, I get an error and the following in LogCat:
09-29 17:36:40.710: ERROR/PlayerDriver(562): Command PLAYER_INIT completed with an error or info PVMFFailure
09-29 17:36:40.730: ERROR/MediaPlayer(25215): error (1, -1)
The content type that the URL returns is audio/x-wav. I The error occurs after calling prepareAsync():
String uri = "http://whatever";
s_Player.setDataSource(uri);
s_Player.setAudioStreamType(AudioManager.STREAM_MUSIC);
s_Player.prepareAsync();
When I replace uri with a file path to the same sound stored in the filesystem, it plays fine. Playing the URL in the Android browser works. So it must be me somehow misusing MediaPlayer. Any ideas, please?
EDIT: it's on the emulator (for now), so permissions are not an issue.
Maybe you didn't request Internet permission in the manifest???

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.

Categories

Resources