我尝试播放来自网络的wav文件。
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
mediaPlayer.setDataSource(url);
mediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
Log.e("SoundPlayerService", "Error preparing music");
}
mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
Log.d(Tag, "Audio is playing from: " + url);
mp.start();
}
});
但它没有播放任何东西。代码有什么问题?
答案 0 :(得分:0)
您应该使用temp[,-c(1,2)][temp[, -c(1,2)] < 0] <- 0
代替mediaPlayer.prepareAsync()