Android: QCMediaPlayer could not be located

KenMasters picture KenMasters · Feb 27, 2015 · Viewed 10.4k times · Source

i have a problem with the mediaplayer since i updatet my android -version to 5.0.2 on my lg-smartphone.

i have a separate class to play the music

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() {

    }
 }

I want to play a soundfile over the Mainactivity with

MediaPlayerService.playAudioFromMediaPlayer(getApplicationContext(), soundID);

but i became the following log-message:

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

With soundpool it works fine, but not with the mediaplayer. What is the reason for that and how can i solve it?

Thanks in advance and sry for my english :)

Answer

James Wolfe picture James Wolfe · Aug 18, 2015

I don't think your platform supports the use of QCMediaPlayer I'm afraid - that's why it's giving you all those errors you can find out more by looking at this source:

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

If I were you I'd stick to using soundpool for the time being.