Downloading an mp3 file from server in android

前端 未结 3 1492
逝去的感伤
逝去的感伤 2020-12-13 22:53

I am trying to create an app that can download music files, .mp3 to be precise, from the server.As I am a rookie in this Android Development field so I will appreciate any h

3条回答
  •  不知归路
    2020-12-13 23:24

    You can do it this way:

        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
        }
    

    Manifest permission:

    
    
    

提交回复
热议问题