Trying to implement local video while network goes off

We are trying to implement local video while network goes off in between live streaming but MediaRecorder throwing illegalStateException when mediaRecorder.start() method

Have you considered using this Wowza Loop A Pre-roll module for switching to an mp4 when the network crashes or when the encoder for the live source disconnects? When the encoder reconnects with a live source, it switches from the mp4 back to the live streaming.

https://www.wowza.com/blog/loop-a-pre-roll-until-a-live-stream-starts

Thanks @Rose Power-Wowza Community Manager for your reply, we are using MediaRecorder which is third party tool w.r.t. wowza for storing video locally when network crashes. Code is working fine and we are able to store the video locally without audio because device resource(MIC - related to Audio source) is still being used by Wowza mp4Writer after network crashes.Please provide appropriate solution.

Note : Sometimes it is releasing audio source & sometimes MediaRecorder throwing IllegalStateException.

Thanks you very much in advance.