Piasy / RxAndroidAudio

Maybe the most robust Android Audio encapsulation library, with partial Rx support.
http://blog.piasy.com/2016/02/24/Robust-Android-Audio-encapsulation/
MIT License
1.57k stars 235 forks source link

When mPlayer is not empty? #34

Open WooYu opened 7 years ago

WooYu commented 7 years ago

public MediaPlayer getMediaPlayer() { return mPlayer; }

Piasy commented 7 years ago

What do you mean? If you didn't start a player, it will return null.

qadirsuh commented 7 years ago

I have started the audio recording. like

mAudioRecorder = AudioRecorder.getInstance();
        mAudioFile = new File(Utils.getTodayAudioDirectory() +
                File.separator + System.nanoTime() + ".file.m4a");

        Log.e("mAudioFile Path", mAudioFile.toString());

        mAudioRecorder.prepareRecord(MediaRecorder.AudioSource.MIC,
                MediaRecorder.OutputFormat.MPEG_4, MediaRecorder.AudioEncoder.AAC,
                mAudioFile);
        mAudioRecorder.startRecord();

Now I wanted to pause it

I tried like mRxAudioPlayer.getMediaPlayer().pause();

But I am getting null FATAL EXCEPTION: main Process: enact.employ.tracking, PID: 1017 java.lang.NullPointerException: Attempt to invoke virtual method 'void android.media.MediaPlayer.pause()' on a null object reference

I am testing on Marshmallow 6.0 device

Piasy commented 7 years ago

Maybe an error happened, please debug it.

qadirsuh commented 7 years ago

Error is your library doesn't support the audio recording pause and play feature. I assumed that mRxAudioPlayer.getMediaPlayer().pause(); will pause my audio recording but its not. Wrong assumption. right?