Android: media player play from url :Failed to open file error - android

I am trying to implement a simple media player in android that contains only two buttons one for play another for pause
Play
String url = " http://host/audio/01_-_Pat.mp3";
public void onClick(View v) {
try{
mPlayer.setDataSource(url);
mPlayer.setOnPreparedListener(MainActivity.this);
mPlayer.prepareAsync();
}catch (Exception e)
{
Log.v("Error", String.valueOf(e));
Toast.makeText(getApplicationContext(), "Exception", Toast.LENGTH_LONG).show();
}
mPlayer.start();
}
I didn't get any exception on this code but i will get this error
*
Failed to open file ' http://host.com/audio/01_-_Pat.mp3'. (No such
file or directory)
*
Actually the url is valid and it contains the audio

Add this line to your code:
mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
String url = " http://host/audio/01_-_Pat.mp3";
public void onClick(View v) {
try{
mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mPlayer.setDataSource(url);
mPlayer.setOnPreparedListener(MainActivity.this);
mPlayer.prepareAsync();
}catch (Exception e)
{
Log.v("Error", String.valueOf(e));
Toast.makeText(getApplicationContext(), "Exception", Toast.LENGTH_LONG).show();
}
mPlayer.start();
}

Related

How to play Base 64 encoded audio in Android

I'm trying to play some base 64 encoded audio in Android, and I've followed various examples to come up with the following code:
MediaPlayer soundPlayer = new MediaPlayer();
try {
soundPlayer.setDataSource(audioData);
soundPlayer.setOnCompletionListener(new OnCompletionListener() {
#Override
public void onCompletion(MediaPlayer mp) {
mp.stop();
mp.release();
}
});
soundPlayer.prepare();
soundPlayer.setVolume(100f, 100f);
soundPlayer.setLooping(false);
soundPlayer.start();
}
catch (Exception e) {
.
.
.
}
When this code executes, I just get silence - and the following error:
08-24 11:38:58.555: W/System.err(18862): java.io.IOException: Prepare
failed.: status=0x1 08-24 11:38:58.555: W/System.err(18862): at
android.media.MediaPlayer.prepare(Native Method) 08-24 11:38:58.555:
W/System.err(18862): at
application.main.Application$27.run(Application.java:233)
Would appreciate if anyone can point out where I'm going wrong. The 'audioData' variable in question (which, if you manage to decode and play it, describes my frustration) is as follows:
data:application/octet-stream;base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TTl7RWBfP7cgdw9vCAZ/2IB+9FRI5geJBGZ7r4e9yabkkZN/kwBXFiPKshMaWVqcIt0iqAQzGrB1aKlZRXcvRB3QYRaj1juIUW5PrKKp909vhEmTJqi6C+nd3gwDRSqj53Lwm/JCx2ujpWHg4GSzhzr0J25JFoe8wqNt4VPpOLoSwQydCZ7bRZQzJefdTMId9KZjnsBBNRvHs/YITU0fsMUspqwMZxey8PDloGhaGG9fLy4OFKlplA0QOyj/ES6S3ucfCigRULMVRQrm73GMS6DyvlSNbBlO0JBUijyuhmsAlwruLC/JUi/qfycz9vP6UXwjJA1idbQdhDyjQYOBBWSA+wObAtiCRYKkv35+bpr24xC7r99YsVj6s2j30vxq1D3kXAbvJr+sfWNWSpom4cF7x3905QEYsYj1oydJRs3Nd2wL8aI4NPeKYLrJNSqSXhtGG5XxmYWJwpDiXdQaX5fFIz65nxFAzxRxMg7KezqypulXxSiLdSulY2x1w5gTTLxVWztQviIYknGsoJhq47BN3V0XMSsksLJjipxT7TCqsNH0JazomASa4GZMbwA8cPN+fvlBb+1qmcbntdkqxsvHXi2lhKjRpl8XzyjQn+K5DiJS+p9P8IEz6QoqPo6WELX76WPY9IXyJNgZ9kO7pFBncr7LBrQr4o1DnUVQlnFp/Flm0GWLH7GYCFw2Bbm6uiQsCp7sY7cVloFkmmgtN+4jtv75bdgDafsTZI90drCFYAVTHBKKfRjxi01E7EM15Hy/irSvXFxeV4gbMQ/2u9kA2GI/29WIzqQW+TOLgaA7lENLrVVQtUxf5Vlmv08oCL86A3u/9E59JYe5dZ7sthg=
Example Code of Playing Base64 encoded audio in Android :
public class MainActivity extends AppCompatActivity {
Button button;
String base64FormattedString="GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQRChYECGFOAZwH/////////FUmpZpkq17GDD0JATYCGQ2hyb21lV0GGQ2hyb21lFlSua7+uvdeBAXPFh+lZ/IvV7yqDgQKGhkFfT1BVU2Oik09wdXNIZWFkAQEAAIC7AAAAAADhjbWERzuA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wQydCZ7bRZQzJefdTMId9KZjnsBBNRvHs/YITU0fsMUspqwMZxey8PDloGhaGG9fLy4OFKlplA0QOyj/ES6S3ucfCigRULMVRQrm73GMS6DyvlSNbBlO0JBUijyuhmsAlwruLC/JUi/qfycz9vP6UXwjJA1idbQdhDyjQYOBBWSA+wObAtiCRYKkv35+bpr24xC7r99YsVj6s2j30vxq1D3kXAbvJr+sfWNWSpom4cF7x3905QEYsYj1oydJRs3Nd2wL8aI4NPeKYLrJNSqSXhtGG5XxmYWJwpDiXdQaX5fFIz65nxFAzxRxMg7KezqypulXxSiLdSulY2x1w5gTTLxVWztQviIYknGsoJhq47BN3V0XMSsksLJjipxT7TCqsNH0JazomASa4GZMbwA8cPN+fvlBb+1qmcbntdkqxsvHXi2lhKjRpl8XzyjQn+K5DiJS+p9P8IEz6QoqPo6WELX76WPY9IXyJNgZ9kO7pFBncr7LBrQr4o1DnUVQlnFp/Flm0GWLH7GYCFw2Bbm6uiQsCp7sY7cVloFkmmgtN+4jtv75bdgDafsTZI90drCFYAVTHBKKfRjxi01E7EM15Hy/irSvXFxeV4gbMQ/2u9kA2GI/29WIzqQW+TOLgaA7lENLrVVQtUxf5Vlmv08oCL86A3u/9E59JYe5dZ7sthg=";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button=findViewById(R.id.btnId);
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
playMedia();
}
});
}
public void playMedia() {
try{
String url = "data:audio/mp3;base64,"+base64FormattedString;
MediaPlayer mediaPlayer = new MediaPlayer();
try {
mediaPlayer.setDataSource(url);
mediaPlayer.prepareAsync();
mediaPlayer.setVolume(100f, 100f);
mediaPlayer.setLooping(false);
} catch (IllegalArgumentException e) {
Toast.makeText(getApplicationContext(), "You might not set the DataSource correctly!", Toast.LENGTH_LONG).show();
} catch (SecurityException e) {
Toast.makeText(getApplicationContext(), "You might not set the DataSource correctly!", Toast.LENGTH_LONG).show();
} catch (IllegalStateException e) {
Toast.makeText(getApplicationContext(), "You might not set the DataSource correctly!", Toast.LENGTH_LONG).show();
} catch (IOException e) {
e.printStackTrace();
}
mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer player) {
player.start();
}
});
mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
#Override
public void onCompletion(MediaPlayer mp) {
mp.stop();
mp.release();
}
});
}
catch(Exception e){
e.printStackTrace();
}
}
}
Also : AudioTrack is recommend to play a single audio resource for Java applications.
your error occurred because of the length of the base64 url limitation. media cannot prepare datasource for the long string. what I found base64 url for around 128 characters maybe work well. For long string you have to split string into pieces and fetch base64 url for small strings.

How can i save a song from my app in android? [duplicate]

This question already has answers here:
Downloading an mp3 file from server in android
(3 answers)
Closed 7 years ago.
i am unable to download the song from internet but i can listen the song but i want to my app to perform as, when i am clicking the play button it should download that song too.
playbtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
mPlayer = new MediaPlayer();
if(web[position] == web[0]){
if(mPlayer.isPlaying()){
mPlayer.stop();
mPlayer.prepareAsync();
mPlayer.seekTo(0);
}
else{
Uri myUri1 = Uri.parse("http://sound21.mp3slash.net/320/indian/bajrangibhaijaan/01%20-%20Selfie%20Le%20Le%20Re%20-%20Bajrangi%20Bhaijaan%20[Songspk.LINK].mp3");
try {
mPlayer.setDataSource(getContext(), myUri1);
} catch (IllegalArgumentException e) {
Toast.makeText(getContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
} catch (SecurityException e) {
Toast.makeText(getContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
} catch (IllegalStateException e) {
Toast.makeText(getContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
} catch (IOException e) {
e.printStackTrace();
}
try {
mPlayer.prepare();
} catch (IllegalStateException e) {
Toast.makeText(getContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
} catch (IOException e) {
Toast.makeText(getContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
}
mPlayer.start();
playbtn.setText("Pause");
}
You mean when you click button , start playing and downloading?
Use DownloadManager to download the audio file.
http://developer.android.com/reference/android/app/DownloadManager.html

Streaming audio from website to app

I'm in the process of building a prototype for a project. I want to be able to stream music from my website to the app.
Here is what I have so far. Trying it with an m3u because I honestly have no idea what else to use for this.
Button buttonPlay;
Button buttonStop;
MediaPlayer mPlayer;
String url = "http://www.*******.com/*****/files.m3u";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
buttonPlay = (Button) findViewById(R.id.play);
buttonPlay.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mPlayer = new MediaPlayer();
mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
mPlayer.setDataSource(url);
} catch (IllegalArgumentException e) {
Toast.makeText(getApplicationContext(), "You might not set the URI correctly! Illegal Argument", Toast.LENGTH_LONG).show();
} catch (SecurityException e) {
Toast.makeText(getApplicationContext(), "You might not set the URI correctly! Security ", Toast.LENGTH_LONG).show();
} catch (IllegalStateException e) {
Toast.makeText(getApplicationContext(), "You might not set the URI correctly! Illegal Statement", Toast.LENGTH_LONG).show();
} catch (IOException e) {
e.printStackTrace();
}
try {
mPlayer.prepare();
} catch (IllegalStateException e) {
Toast.makeText(getApplicationContext(), "You might not set the URI correctly! Prepare Illegal State", Toast.LENGTH_LONG).show();
} catch (IOException e) {
Toast.makeText(getApplicationContext(), "You might not set the URI correctly! Prepare IO", Toast.LENGTH_LONG).show();
}
mPlayer.start();
}
});
buttonStop = (Button) findViewById(R.id.stop);
buttonStop.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
if(mPlayer!=null && mPlayer.isPlaying()){
mPlayer.stop();
}
}
});
Them problem is it throws IOexception after prepare. Now I read somewhere you have to download m3u files and then read them line by line. If that is the case, is there a better way? I'm attempting to make sort of a radio app for testing purposes that will play songs at random, not in order, so I don't want to hard code them MP3 files,
you cant just prepare a stream because it needs to download asynchronously. you will need to do this
Button buttonPlay;
Button buttonStop;
MediaPlayer mPlayer;
String url = "http://www.*******.com/*****/files.m3u";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
buttonPlay = (Button) findViewById(R.id.play);
buttonPlay.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mPlayer = new MediaPlayer();
mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
mPlayer.setDataSource(url);
} catch (IllegalArgumentException e) {
Toast.makeText(getApplicationContext(), "You might not set the URI correctly! Illegal Argument", Toast.LENGTH_LONG).show();
} catch (SecurityException e) {
Toast.makeText(getApplicationContext(), "You might not set the URI correctly! Security ", Toast.LENGTH_LONG).show();
} catch (IllegalStateException e) {
Toast.makeText(getApplicationContext(), "You might not set the URI correctly! Illegal Statement", Toast.LENGTH_LONG).show();
} catch (IOException e) {
e.printStackTrace();
}
try {
mPlayer.prepareAsync();
mPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer mp) {
mPlayer.start();
}
};);
} catch (IllegalStateException e) {
Toast.makeText(getApplicationContext(), "You might not set the URI correctly! Prepare Illegal State", Toast.LENGTH_LONG).show();
} catch (IOException e) {
Toast.makeText(getApplicationContext(), "You might not set the URI correctly! Prepare IO", Toast.LENGTH_LONG).show();
}
}
});
buttonStop = (Button) findViewById(R.id.stop);
buttonStop.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
if(mPlayer!=null && mPlayer.isPlaying()){
mPlayer.stop();
}
}
});

Playing sound from SDCard with MediaPlayer?

Let me explain clearly:
I have folder named "Sounds" and there are some .ogg files to play.
I got the folder path using Environment.getExternalStorageDirectory().getAbsolutePath() + mySoundsPath;.
I got all list from that folder and save it to array: List<String> soundList;
My question is:
How to call the sound from soundList that i created so they all can be played??
Should it need to decoded(like images, decoded to Bitmap)??
Sorry for my grammar.
Thanks in advance.
Use the below link for the reference
http://developer.android.com/reference/android/media/MediaPlayer.html
and you can try small code sample as well
http://davanum.wordpress.com/2007/12/29/android-videomusic-player-sample-from-local-disk-as-well-as-remote-urls/
public void play(String path) {
count++;
playFile=path;
//showNotification();
new NotificationPanel(activity);
if(mediaPlayer!=null && mediaPlayer.isPlaying()){
Log.d("*****begin*****", "playing");
stopPlaying();
Log.d("*****begin*****", "stoping");
} else{
Log.d("*****begin*****", "nothing");
}
Uri myUri1 = Uri.parse(path);
mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
mediaPlayer.setDataSource(activity, myUri1);
} catch (IllegalArgumentException e) {
Toast.makeText(activity, "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
} catch (SecurityException e) {
Toast.makeText(activity, "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
} catch (IllegalStateException e) {
Toast.makeText(activity, "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
} catch (IOException e) {
e.printStackTrace();
}
try {
mediaPlayer.prepare();
} catch (IllegalStateException e) {
Toast.makeText(activity, "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
} catch (IOException e) {
Toast.makeText(activity, "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
}
mediaPlayer.start();
}
private void stopPlaying() {
if (mediaPlayer != null) {
mediaPlayer.stop();
mediaPlayer.release();
mediaPlayer = null;
}
}

MediaPlayer error android

I have an activity which has a series of buttons which when pressed should play an audio file. I have been trying to implement this using MediaPlayer however I cant get it to work.
Here is the code I have been trying:
final MediaPlayer mp = new MediaPlayer();
Button ger1play = (Button) findViewById(R.id.ger1play);ger1play.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
mp.setDataSource(this, R.raw.greet_1);
mp.prepare();
mp.start();
}
});
The setDateSource method doesnt seem to work, can anyone tell me where I am going wrong?
I would like to then set the mediaPlayer to the relevant audio file based on which button is pressed, is this possible?
Updated
final MediaPlayer mp = new MediaPlayer();
Button ger1play = (Button) findViewById(R.id.ger1play);ger1play.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
try {
Uri myUri = Uri.parse(R.raw.greet_1);
mp.setDataSource(GreetingsLesson.this, R.raw.greet_1);
mp.prepare();
mp.start();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
});
try this:
final MediaPlayer mp = new MediaPlayer();
Button ger1play = (Button) findViewById(R.id.ger1play);ger1play.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
try {
mp.setDataSource(CurrentActivity.this, R.raw.greet_1);
mp.prepare();
mp.start();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
});
Ifyou want to send the media player object with one of the files fromapplication raw resources or from application assets files you can dothat as follows:
try {
AssetFileDescriptor fd = getResources().openRawResouceFd(R.raw.greet_1);
mp.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength());
mp.start();
fd.close();
} catch (IllegalArgumentException e) {
// handle exception
} catch (IllegalStateException e) {
// handle exception
} catch (IOException e) {
// handle exception
}
Why not just use
mp = MediaPlayer.create(this, R.raw.greet_1);
Then you don't need the prepare or start.
Are you running this in an emulator? If so check your AVD manager has under hardware, the property "Audio playback support | yes" added

Categories

Resources