Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to play Audio file Mp3 from the server [duplicate]

I want to play audio from the live server. I don't want to download these audio files. Format of these files are mp3.working on android java.

like image 475
M.ArslanKhan Avatar asked Dec 17 '13 07:12

M.ArslanKhan


People also ask

How do I play MP3 files in terminal?

If you want to play the MP3 in the GUI, use the “-gui” flag. If you want to disable the GUI, then use “-nogui” instead. Looping is also supported. THe following command will run your selected MP3 file(s) for 100 times.

How do I link audio to MP3?

To link to an MP3 file, you must first upload the MP3 file either to a cloud storage service like Google Drive or iCloud, or to an online music service like SoundCloud. After uploading the music, you can share it via the link.

How do I play MP3 files in Ubuntu terminal?

Click on Media from the top menu bar. Then from the drop-down list, select Open File. In the window that appears, choose the mp3 file that you want to play and click on Open. It will instantly play the mp3 file in VLC player.


2 Answers

try {
    MediaPlayer player = new MediaPlayer();
    player.setAudioStreamType(AudioManager.STREAM_MUSIC);
    player.setDataSource("http://xty/MRESC/images/test/xy.mp3");
    player.prepare();
    player.start();    
} catch (Exception e) {
    // TODO: handle exception
}
like image 77
dipali Avatar answered Oct 04 '22 20:10

dipali


Try doing this:

MediaPlayer mp = new MediaPlayer(/*Your-Context*/);
mp.setDataSource(/*MP3 file's Url*/);
mp.setOnPreparedListener(new OnPreparedListener(){
onPrepared(MediaPlayer mp)
{
mp.start();
}
});
mp.prepareAsync();
like image 41
Abhishek Shukla Avatar answered Oct 04 '22 20:10

Abhishek Shukla