public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MediaPlayer player = MediaPlayer.create(this, Uri.parse("http://www.urlto.com/file.mp3"));
player.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.start();
}
});
} 用这种方式是因为我用MediaPlayer mp = new MediaPlayer();
try { .setDataSource("http://www.urltofile.com/file.mp3");
mp.prepare();
mp.start();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} mp
竟然有错 所有就换用了上面的方式
标签:www,方式,player,MediaPlayer,音乐,printStackTrace,mp,catch,播放
From: https://blog.51cto.com/u_16166892/6525372