Skip to content

Commit

Permalink
fix: autoplay videos to avoid issues in iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
fbaiodias committed Dec 5, 2018
1 parent 27bb051 commit e0feb7f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"test": "jest",
"clean": "rm -rf lib",
"build": "babel src -d lib --copy-files --ignore **/*.stories.js,**/*.spec.js",
"prebuild": "npm run clean",
"prepublish": "NODE_ENV=production npm run build",
"prebuild": "yarn run clean",
"prepublish": "NODE_ENV=production yarn run build",
"precommit": "lint-staged",
"start": "npm run storybook",
"start": "yarn run storybook",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook",
"travis-deploy-once": "travis-deploy-once",
Expand Down
4 changes: 3 additions & 1 deletion src/video-recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ const getVideoInfo = videoBlob =>
const videoTag = document.createElement('video')
videoTag.preload = 'metadata'
videoTag.muted = true
videoTag.defaultMuted = true
videoTag.playsInline = true
videoTag.autoplay = true

videoTag.addEventListener('loadeddata', function () {
const duration = videoTag.duration * 1000
Expand All @@ -94,7 +96,6 @@ const getVideoInfo = videoBlob =>
})

videoTag.src = window.URL.createObjectURL(videoBlob)
videoTag.play()
})

export default class VideoRecorder extends Component {
Expand Down Expand Up @@ -474,6 +475,7 @@ export default class VideoRecorder extends Component {
loop
muted={isReplayVideoMuted}
playsInline
autoPlay
onClick={() =>
this.setState({ isReplayVideoMuted: !isReplayVideoMuted })
}
Expand Down

0 comments on commit e0feb7f

Please sign in to comment.