質問

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());
                }
            });

誰でも、無効な状態の例外ではないプレイヤーを処理するのを助けることができます

役に立ちましたか?

解決

これをチェックして リンク. 。エラーコードの説明があります。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top