Android:无法找到QCMediaPlayer

时间:2015-02-27 12:42:42

标签: android android-mediaplayer

我的媒体播放器有问题,因为我在我的lg-smartphone上将我的android -version更新为5.0.2。

我有一个独立的课程来播放音乐

public class MediaPlayerService {

    public static MediaPlayer mediaPlayer;
    private static SoundPool soundPool;
    public static boolean isplayingAudio = false;
    static int soundID;

    public static enum State {
        Stopped, 
        Playing, 
    }

    static State mState = State.Stopped;

    public static void playAudioFromMediaPlayer(Context c) {

        mediaPlayer = new MediaPlayer();
        mediaPlayer = MediaPlayer.create(c, R.raw.hooray);
        if (!mState.equals(State.Stopped)) {
                mediaPlayer.start();
                mState = State.Playing;
        }
    }

    @SuppressWarnings("deprecation")
    public static void loadAudioFromSoundPool(Context c, int id) {

        soundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 100);   
        soundID = soundPool.load(c, SoundList.soundList.get(id), 1);
    }

    public static void playAudioFromSoundPool() {

        soundPool.play(soundID, 1, 1, 0, 0, 1);
    }

    public static boolean isMediaPlayerPlaying() {
        if (mState.equals(State.Playing)) {
            return true;
        }
        return false;
    }

    public void releaseMediaPlayer() {
        if(mediaPlayer != null || mediaPlayer.isPlaying()) {    
            mediaPlayer.stop();
            mediaPlayer.release();
            mediaPlayer = null;
        }
    }       

    public void releaseSoundPool() {

    }
 }

我想使用

在Mainactivity上播放声音文件
MediaPlayerService.playAudioFromMediaPlayer(getApplicationContext(), soundID);

但我成了以下日志消息:

02-27 12:36:15.829: E/ExtMediaPlayer-JNI(11743): QCMediaPlayer could not be located....
02-27 12:36:15.829: E/MediaPlayer-JNI(11743): QCMediaPlayer mediaplayer NOT present
02-27 12:36:15.854: E/ExtMediaPlayer-JNI(11743): QCMediaPlayer could not be located....
02-27 12:36:15.854: E/MediaPlayer-JNI(11743): QCMediaPlayer mediaplayer NOT present
02-27 12:36:15.908: E/MediaPlayer(11743): Should have subtitle controller already set
02-27 12:36:15.930: E/ExtMediaPlayer-JNI(11743): QCMediaPlayer could not be located....
02-27 12:36:15.930: E/MediaPlayer-JNI(11743): QCMediaPlayer mediaplayer NOT present
02-27 12:36:15.931: E/ExtMediaPlayer-JNI(11743): QCMediaPlayer could not be located....
02-27 12:36:15.931: E/MediaPlayer-JNI(11743): QCMediaPlayer mediaplayer NOT present
02-27 12:36:15.958: E/MediaPlayer(11743): Should have subtitle controller already set
02-27 12:36:15.962: E/MediaPlayer(11743): Should have subtitle controller already set
02-27 12:36:16.018: E/MediaPlayer(11743): Should have subtitle controller already set

使用soundpool它可以正常工作,但不适用于媒体播放器。这是什么原因,我该如何解决?

提前致谢我的英语:)

1 个答案:

答案 0 :(得分:3)

我认为您的平台不支持使用QCMediaPlayer我担心 - 这就是为什么它会通过查看此来源为您提供所有可以找到的错误的原因:

https://github.com/fallowu/slim_hardware_qcom_media/blob/master/QCMediaPlayer/com/qualcomm/qcmedia/QCMediaPlayer.java

如果我是你,我暂时坚持使用soundpool。