开发者

MediaPlayer playing files on AVD, on PDA throwing errors

开发者 https://www.devze.com 2023-03-11 07:07 出处:网络
This is my method in service for playing files, on AVD everything works fine, no errors, when I click the control开发者_如何转开发 on PDA I get these LogCat events: http://pastebay.com/125483. I have

This is my method in service for playing files, on AVD everything works fine, no errors, when I click the control开发者_如何转开发 on PDA I get these LogCat events: http://pastebay.com/125483. I have no clue what is happening. Please advise.

public void playAudio (int playAudio) { 

    player = MediaPlayer.create(this, playAudio);

    try {           
        if (player != null) { 
            player.stop();          
            }
        player.prepare();
        player.start();

    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();

        } finally {

    }

}


I solved it, the problem was I called prepare(); after MediaPlayer.create since it prepares the MediaPlayer already.

0

精彩评论

暂无评论...
验证码 换一张
取 消