Skip to content

Commit

Permalink
add saveAs (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
thijstriemstra committed Nov 26, 2016
1 parent 24eeb02 commit 212953c
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
videojs-record changelog
========================

1.6.0 - unreleased
------------------

- Added `saveAs` method that shows a browser dialog window where the user can store
the recorded media locally (#97)


1.5.0 - 2016/09/30
------------------

Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ player.recorder.destroy();
| --- | --- |
| `isRecording` | Returns a boolean indicating whether recording is active or not. |
| `getRecordType` | Get recorder type as string. Either `image_only`, `animation`, `audio_only`, `video_only` or `audio_video`. |
| `saveAs` | Show save as dialog in browser so the user can [store the recorded media locally](#save-data). |
| `destroy` | Destroys the recorder instance and children (including the video.js player). |
| `reset` | Not as destructive as `destroy`: use this if you want to reset the player interface and recorder state. |
| `stopDevice` | Stop the recording and the active audio and/or video device(s). |
Expand Down Expand Up @@ -279,6 +280,22 @@ Note that in the Chrome browser `player.recordedData` returns an object with
`audio` and `video` properties when recording both audio/video. In Firefox
it returns a single WebM Blob object containing both audio and video.

### Save data

Use the `saveAs` method to show a 'Save as' browser dialog where the user can
choose the storage location for the recorded data. It accepts a `name` object that
contains a mapping between the media type and the filename. For example::

```javascript
player.on('finishRecord', function()
{
// show save as dialog
player.recorder.saveAs({'video': 'my-video-file-name'});
});
```

### Upload data

Check the [jquery.fileupload](https://github.com/collab-project/videojs-record/blob/master/examples/upload/jquery.fileupload.html) or [Fine Uploader](https://github.com/collab-project/videojs-record/blob/master/examples/upload/fine-uploader.html)
examples on how to upload the data to a server.

Expand Down
36 changes: 36 additions & 0 deletions src/js/videojs.record.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,24 @@
this.engine.stopRecording(this.onStopRecording.bind(this));
},

/**
* Show save as dialog in browser so the user can store the recorded media
* locally.
*
* @private
* @param {object} name - Object with names for the particular blob(s)
* you want to save. File extensions are added automatically. For
* example: {'video': 'name-of-video-file'}. Supported keys are
* 'audio', 'video' and 'gif'.
*/
saveAs: function(name)
{
if (this.engine && name !== undefined)
{
this.engine.save(name);
}
},

/**
* Invoked when recording is stopped and resulting stream is available.
*
Expand Down Expand Up @@ -1352,6 +1370,24 @@
}
},

/**
* Show save as dialog in browser so the user can store the recorded media
* locally.
*
* @private
* @param {object} name - Object with one or more names for the particular
* blob(s) you want to save. File extensions are added automatically.
* For example: {'video': 'name-of-video-file'}. Supported keys are
* 'audio', 'video' and 'gif'.
*/
saveAs: function(name)
{
if (this.engine && name !== undefined)
{
this.engine.saveAs(name);
}
},

/**
* Destroy plugin and players and cleanup resources.
*/
Expand Down

0 comments on commit 212953c

Please sign in to comment.