File tree Expand file tree Collapse file tree 1 file changed +25
-13
lines changed Expand file tree Collapse file tree 1 file changed +25
-13
lines changed Original file line number Diff line number Diff line change @@ -171,19 +171,7 @@ export default class VideoRecorder extends Component {
171171 this . state . isReplayingVideo &&
172172 ! prevState . isReplayingVideo
173173 ) {
174- this . replayVideo . addEventListener ( 'loadedmetadata' , ( ) => {
175- const playPromise = this . replayVideo . play ( )
176-
177- if ( playPromise ) {
178- playPromise . catch ( err => {
179- if ( err . name === 'NotAllowedError' ) {
180- console . warn ( err )
181- return
182- }
183- throw err
184- } )
185- }
186- } )
174+ this . tryToUnmuteReplayVideo ( )
187175 }
188176 }
189177
@@ -299,6 +287,30 @@ export default class VideoRecorder extends Component {
299287 return true
300288 }
301289
290+ tryToUnmuteReplayVideo = ( ) => {
291+ const video = this . replayVideo
292+ video . muted = false
293+
294+ let playPromise = video . play ( )
295+ if ( ! playPromise ) {
296+ video . muted = true
297+ return
298+ }
299+
300+ playPromise
301+ . then ( ( ) => {
302+ this . setState ( { isReplayVideoMuted : false } )
303+ } )
304+ . catch ( err => {
305+ console . warn ( 'Could not autoplay replay video' , err )
306+ video . muted = true
307+ return video . play ( )
308+ } )
309+ . catch ( err => {
310+ console . warn ( 'Could play muted replay video after failed autoplay' , err )
311+ } )
312+ }
313+
302314 handleDataAvailable ( event ) {
303315 if ( this . isDataHealthOK ( event ) ) {
304316 this . recordedBlobs . push ( event . data )
You can’t perform that action at this time.
0 commit comments