ScreenRecorder icon indicating copy to clipboard operation
ScreenRecorder copied to clipboard

Request (init) MediaProjection only once

Open anonym24 opened this issue 7 years ago • 0 comments
trafficstars

This project always trying to call intent and set MediaProjection when you start recording

I don't think it's a good algorithm, please make call to intent only once and then just reuse the same instance of MediaProjection

    private void release() {
        /*if (mMediaProjection != null) {
            mMediaProjection.unregisterCallback(mProjectionCallback);
        }*/
        if (mVirtualDisplay != null) {
            mVirtualDisplay.release();
            mVirtualDisplay = null;
        }

        mVideoOutputFormat = mAudioOutputFormat = null;
        mVideoTrackIndex = mAudioTrackIndex = INVALID_INDEX;
        mMuxerStarted = false;

        if (mWorker != null) {
            mWorker.quitSafely();
            mWorker = null;
        }
        if (mVideoEncoder != null) {
            mVideoEncoder.release();
            mVideoEncoder = null;
        }
        if (mAudioEncoder != null) {
            mAudioEncoder.release();
            mAudioEncoder = null;
        }

        /*if (mMediaProjection != null) {
            mMediaProjection.stop();
            mMediaProjection = null;
        }*/
        if (mMuxer != null) {
            try {
                mMuxer.stop();
                mMuxer.release();
            } catch (Exception e) {
                // ignored
            }
            mMuxer = null;
        }
        mHandler = null;
    }

anonym24 avatar Jun 12 '18 09:06 anonym24