Skip to content

A plugin for clappr which adds a button to take an image capture of the current video screen

License

Notifications You must be signed in to change notification settings

chriswiggins/clappr-capture-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm version

Clappr Capture Plugin

A plugin for clappr which adds a button to capture a base64 jpeg image of the current frame. Emits an event with the base64 data which you can use elsewhere in your application (sending to a remote endpoint, etc)

Screenshot

Usage

Add both Clappr and the capture plugin scripts to your HTML:

<head>
  <script type="text/javascript" src="http://cdn.clappr.io/latest/clappr.min.js"></script>
  <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/clappr-capture-plugin@latest/dist/clappr-capture-plugin.js"></script>
</head>

You can also find the project on npm: https://www.npmjs.com/package/clappr-capture-plugin

Then just add ClapprCapturePlugin into the list of plugins of your player instance.

var player = new Clappr.Player({
  source: "http://your.video/here.mp4",
  plugins: [ClapprCapturePlugin]
});

That's it, a button will be shown on the media control to enable capture. This only works with playback tech's that use a <video> tag to display video

To capture the event, just listen to the capture:base64 event on the mediaControl container:

player.core.mediaControl.on('capture:base64', (b64) => {
  var myWindow = window.open("", "PictureWindow");
  myWindow.document.write(`<img src="${b64}" />`);
});

Demo

To run the demo start a web server with the root directory being the root of this repo, and then browse to the "index.html" file in the "demo" folder. The demo will open a new window with the captured image after the button has been clicked

Development

Install dependencies:

npm install

Build:

npm run build

Minified version:

npm run release

Credit to Tom Jenkinson (@tjenkinson) for his PIP plugin, which this plugin used as a base template.

About

A plugin for clappr which adds a button to take an image capture of the current video screen

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published