{
chunks.push(e.data)
}
this._recorder.onstop = () => {
this._recording = false
stream.getTracks()
.forEach(track => track.stop())
fixWebmDuration(
new Blob(chunks, { type: 'video/mp4' }),
Date.now() - start
).then(blob => {
this._src = URL.createObjectURL(blob)
})
}
this._recorder.start()
})
.catch(() => {
this._recording = false
})
} else {
this._recorder.stop()
}
},
download () {
Object.assign(
document.createElement('a'),
{
href: this._src,
download: `video_${new Date(Date.now() - new Date().getTimezoneOffset() * 60000).toISOString().substring(0, 16).replace(/[T:-]/g, '_')}mp4`
}
).click()
},
formatTime (value) {
return `${Math.floor(value / 60)}:${(value % 60 | 0).toString().padStart(2, 0)}`
}
}"
>