fixed video playback problem by rearranging js functions