媒体播放器android中的错误代码1,-4

时间:2012-02-17 09:38:42

标签: android android-mediaplayer

我在Android媒体播放器中收到了带有1,-4数字的错误代码

我使用此代码在我的服务中播放音乐

   public void playNextSong(/* String manualUrl */) {
    mState = State.Stopped;
    relaxResources(true); // release everything except MediaPlayer

    AudioFile file = playList.nextFile();
    if (file == null) {
        say("Tidak ada lagu di playlist");
        return;
    }

    try {
        // set the source of the media player a a content URI
        createMediaPlayerIfNeeded();
        mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
        mPlayer.setDataSource(getApplicationContext(), file.getUri());

        mState = State.Preparing;
        // MUST call this!
        setUpAsForeground(file.getTitle() + " (loading)");

        // starts preparing the media player in the background. When it's
        // done, it will call
        // our OnPreparedListener (that is, the onPrepared() method on this
        // class, since we set
        // the listener to 'this').
        //
        // Until the media player is prepared, we *cannot* call start() on
        // it!
        mPlayer.prepareAsync();

    } catch (IOException ex) {
        Log.e("MusicService",
                "IOException playing next song: " + ex.getMessage());
        ex.printStackTrace();
    }
    }

我在我的代码的摇动监听器中使用它

  mSensorListener
            .setOnShakeListener(new ShakeEventListener.OnShakeListener() {

                public void onShake() {
                    musicService.playNextSong();
                    updateInformation(musicService.playList.getCurrent());
                }
            });

任何人都可以帮助处理未处于无效状态异常的玩家

1 个答案:

答案 0 :(得分:1)

检查link。它有错误代码的描述。