Refactoring the javascript calls and the state machine of the video
recorder.