Skip to content

Commit

Permalink
fix: fixed issue of unable to stop recording in case of safari (#118)
Browse files Browse the repository at this point in the history
* fix: fixed issue of unable to stop recording in case of safari

 1. Added mimeType mp4 for Safari Browser Support
 2. Bypassed function for fixMetaData in case of Safari

* fix: updated to fix ios issue for video el

 Added playsInline attribute
  • Loading branch information
Swapnil256 authored Jun 9, 2021
1 parent f780b19 commit 4f367cc
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/video-recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const MIME_TYPES = [
'video/webm;codecs="vp8,opus"',
'video/webm;codecs=h264',
'video/webm;codecs=vp9',
'video/webm'
'video/webm',
'video/mp4'
]

const CONSTRAINTS = {
Expand Down Expand Up @@ -383,7 +384,7 @@ export default class VideoRecorder extends Component {
? MIME_TYPES.find(window.MediaRecorder.isTypeSupported)
: 'video/webm'

return mimeType || ''
return (this.mediaRecorder && this.mediaRecorder.mimeType) || mimeType || ''
}

isDataHealthOK = (event) => {
Expand Down Expand Up @@ -593,6 +594,10 @@ export default class VideoRecorder extends Component {

// see https://bugs.chromium.org/p/chromium/issues/detail?id=642012
fixVideoMetadata = (rawVideoBlob) => {
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent)
if (isSafari) {
return Promise.resolve(rawVideoBlob)
}
// see https://stackoverflow.com/a/63568311
Blob.prototype.arrayBuffer ??= function () {
return new Response(this).arrayBuffer()
Expand Down Expand Up @@ -794,6 +799,7 @@ export default class VideoRecorder extends Component {
ref={(el) => (this.cameraVideo = el)}
autoPlay
muted
playsInline
/>
{switchCameraControl}
</CameraView>
Expand Down

1 comment on commit 4f367cc

@vercel
Copy link

@vercel vercel bot commented on 4f367cc Jun 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.