android播放MP3一个警告:IllegalStateException

阅读更多
解决办法 在
prepared() 前调用 stop()

[c-sharp] view plaincopy

    player = MediaPlayer.create(MusicService.this, R.raw.my); 
            try { 
                if (player != null) { 
                    player.stop(); 
                } 
                player.prepare(); 
            } catch (IllegalStateException e) { 
                // TODO Auto-generated catch block 
                e.printStackTrace(); 
            } catch (IOException e) { 
                // TODO Auto-generated catch block 
                e.printStackTrace(); 
            } 
            player.start(); 

你可能感兴趣的:(mediaplayer)