刚刚将我的Galaxy s5从4.4.4更新到5.0,并且我的媒体播放器代码已损坏。在更新之前,一切工作正常,在我的nexus 7平板电脑上也是如此。我从服务器获取网址,并尝试从服务器流式传输mp3。下面的代码全部在onpostexecute方法中的asynctask内部完成。
try
{
if (mediaPlayer == null)
{
mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setDataSource(sUrl);
mediaPlayer.setOnPreparedListener(this);
mediaPlayer.prepareAsync();
}
}
catch (IOException e)
{
e.printStackTrace();
}
@Override
public void onPrepared(MediaPlayer mp)
{
mp.start();
}
这是我的日志
04-26 21:44:19.021 4660-4671/com.reach.sledgehammerlabs.reach D/MediaHTTPConnection﹕ filterOutInternalHeaders: key=User-Agent, val= Samsung SAMSUNG-SM-G900A stagefright/Beyonce/1.1.9 (Linux;Android 5.0)
04-26 21:44:19.021 4660-4725/com.reach.sledgehammerlabs.reach D/MediaHTTPConnection﹕ setReadTimeout with 30000ms
04-26 21:44:19.021 4660-4725/com.reach.sledgehammerlabs.reach I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
04-26 21:44:19.031 4660-4725/com.reach.sledgehammerlabs.reach I/System.out﹕ KnoxVpnUidStorageknoxVpnSupported API value returned is false
04-26 21:44:19.171 4660-4674/com.reach.sledgehammerlabs.reach D/MediaHTTPConnection﹕ setReadTimeout with 30000ms
04-26 21:44:19.171 4660-4674/com.reach.sledgehammerlabs.reach I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
04-26 21:44:19.181 4660-4674/com.reach.sledgehammerlabs.reach I/System.out﹕ KnoxVpnUidStorageknoxVpnSupported API value returned is false
04-26 21:44:19.351 4660-4725/com.reach.sledgehammerlabs.reach V/MediaPlayer﹕ message received msg=100, ext1=1, ext2=-2147483648
04-26 21:44:19.351 4660-4725/com.reach.sledgehammerlabs.reach E/MediaPlayer﹕ error (1, -2147483648)
04-26 21:44:19.351 4660-4725/com.reach.sledgehammerlabs.reach V/MediaPlayer﹕ callback application
04-26 21:44:19.351 4660-4725/com.reach.sledgehammerlabs.reach V/MediaPlayer﹕ back from callback
04-26 21:44:19.351 4660-4660/com.reach.sledgehammerlabs.reach E/MediaPlayer﹕ Error (1,-2147483648)
之所以无法始终正常运行,是因为某些网址中有空格,并且处理不正确。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句