codekraft-studio / vue-record

VueJs components for MediaRecorder API
https://codekraft-studio.github.io/vue-record/
MIT License
95 stars 57 forks source link
mediarecorder mediarecorder-api vuejs vuejs-components

vue-record

custom components for MediaRecorder API

NPM version Dependency Status License

Checkout the demo to see it in action.

Installation

Download the project using your favourite package manager:

npm install @codekraft-studio/vue-record

Load it inside your project and use it:

import Vue from 'vue'
import VueRecord from '@codekraft-studio/vue-record'

Vue.use(VueRecord)

Now you have access to the global defined components, here an example:

<VueRecordAudio />
<VueRecordVideo />

Usage

Use the components in your template with different modes and properties to customize the behavior and the recording output.

Both of the provided components can be used as the following pseudo code example:

<Component :mode="recMode" @stream="onStream" @result="onResult" />

Modes

The are only two usage modes and can be selected with the mode property:

Events

By default it's on hold mode, so the recording start when the button is pressed and stops when the button is released. But you can change this behaviour using a different mode, the available modes are: hold and press.


Examples

Recording Audio

It's simple as adding the component and listening for the result event:

<vue-record-audio @result="onResult" />
export default {
  methods: {
    onResult (data) {
      console.log('The blob data:', data);
      console.log('Downloadable audio', window.URL.createObjectURL(data));
    }
  }
}

We're using this polyfill for Safari.

Recording Video

It's simple as adding the component and listening for the result event:

<vue-record-video @result="onResult" />
export default {
  methods: {
    onResult (data) {
      console.log('The blob data:', data);
      console.log('Downloadable video', window.URL.createObjectURL(data));
    }
  }
}

It doesn't work on Safari, we should consider this polyfill.


License

Released with MIT License © codekraft-studio