Android Media Player无法播放下一个流
作者:互联网
我目前有一个流媒体mp3的媒体播放器,完成后应该转到下一个URL.但是,它没有播放.难道我做错了什么?我originall在字符串数组中有网址,但更改了它仍然无法正常工作.它超时并且力关闭.
码:
尝试{
houseMediaPlayer.setDataSource(housePlaylistString [0]);
houseMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
houseMediaPlayer.prepare();
} catch(IllegalArgumentException e){
// TODO自动生成的catch块
e.printStackTrace();
} catch(IllegalStateException e){
// TODO自动生成的catch块
e.printStackTrace();
} catch(IOException e){
// TODO自动生成的catch块
e.printStackTrace();
}
`houseMediaPlayer.setOnCompletionListener(new OnCompletionListener(){
@Override
public void onCompletion(MediaPlayer mp) {
// TODO Auto-generated method stub
try {
houseMediaPlayer.setDataSource("http://dl.dropbox.com/u/24535120/Reminded%20-%20Tyga%20ft.%20Adele.mp3");
houseMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
houseMediaPlayer.prepare();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
houseMediaPlayer.start();
}
});`
解决方法:
检查此:Playing audio files one after another in android
标签:stream,media-player,android,mp3 来源: https://codeday.me/bug/20191208/2090126.html