Android Mediaplayer streaming audio distorted
The audio being played through my Android app is sounded heavily distorted, almost demonised! I've tried running the application on various versions of android and updating the setAudioStreamType to setAudioAttributes but have had no luck. I'm not sure if it is the stream of the application that is causes this. Below is the class which I use to configure and stream the mp3 file from the url.
public class RadioClient extends IntentService {
final String STATION_URL = "http://wi-icecast.monroe.edu/wirq.mp3";
public static MediaPlayer mediaPlayer = new MediaPlayer();
public RadioClient() {
super("RadioClient-Started");
}
@Override
protected void onHandleIntent(@Nullable Intent intent) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mediaPlayer.setAudioAttributes(new AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
.build());
}
else {
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
}
try {
mediaPlayer.setDataSource(STATION_URL);
} catch (IOException e) {
e.printStackTrace();
}
try {
mediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
}
mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mediaPlayer.start();
}
});
}
}
I think that my issue has to do with buffering. Maybe my connection is not strong enough, but I've gotten MediaPlayerNative: info/warning (701, 0), 702, and 703 errors.
链接地址: http://www.djcxy.com/p/61398.html上一篇: Maven运行项目