2

While using MediaRecorder to record the canvas and its animation, if I minimize the browser or switch the tab, the recorder will:
- In Chrome, nothing is recorded;
- In FireFox, only some frames are recorded, which is also not working.

My Question is:
How to keep recording while user switch tabs or minimize their browser?
Thanks!

soundquiet
  • 485
  • 2
  • 8
  • It's actually not the MediaRecorder that doesn't record anything, but the canvas that doesn't draw anything. However this question has already been asked, let me find it... – Kaiido Oct 28 '19 at 07:48
  • Hmm.. so my memory serves me bad apparently. The one I had in mind is this [Q/A](https://stackoverflow.com/questions/40687010/canvascapturemediastream-mediarecorder-frame-synchronization/40691112#) where the solution provided should work for your case (at least in Chrome). However I though the question there was asking specifically about this blurred state but it seems it didn't, so it's not a perfect dupe target even though the answer could apply here too... – Kaiido Oct 28 '19 at 07:56
  • @Kaiido so the solution is solving by change the rendering method? – soundquiet Oct 28 '19 at 08:18
  • Yes, instead of using one of the usaul timer methods (e.g requestAnimationFram or setTImeout/setInterval) which gets throttled, using the WebAudioContext API allows to run in a non throttled context. However beware that's very hacky and browsers updates already did break this more than once in last few years. – Kaiido Oct 28 '19 at 08:20
  • @Kaiido Another quick question, have you noticed that recorder.onstart is not triggered in Safari? I want to locate the wrong behavior of my code...thanks! – soundquiet Oct 29 '19 at 09:47
  • In Safari? Which version? My 12.1.2 apparently still doesn't have support for the MediaRecorder. Ah I see it's behind an "experimental" flag. Maybe don't expect a stable and fully specs compliant behavior yet. And indeed `MediaRecorder.prototype.onstart` is undefined there. – Kaiido Oct 29 '19 at 09:54
  • yeah, so sad. It's got `onstop``ondataavailable` except `onstart`:-( – soundquiet Oct 29 '19 at 10:48
  • And you don't control when start is being called? WHat do you do in this onstart event exactly? – Kaiido Oct 29 '19 at 10:52
  • haha, i want to do something if the recorder is start. now i just write this part of code following `recorder.start()` – soundquiet Oct 29 '19 at 14:04

0 Answers0