ScreenRecorder
ScreenRecorder copied to clipboard
Request (init) MediaProjection only once
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;
}