how to play audio file from server in android

后端 未结 2 460
情深已故
情深已故 2020-12-09 06:40

I want to download audio file from url and play that audio file in my device.how to implement this concept in my application.please help me

Thanks Friends

2条回答
  •  半阙折子戏
    2020-12-09 07:31

    Try below code:-

    private void PlayFile() {
        try {
            mp.reset();
            Uri uri = Uri.parse("http://soundcloud.com/storynory/the-valentine-witch-mp3/download.mp3");
            mp.setDataSource(this, uri); // "this" refers to context
            mp.prepare();
            mp.start();
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }
    }
    

    If you are required "Download MP3" code then i will post that code also.

提交回复
热议问题