screenshot
screenshot plugin。SourceCode
pluginName: screenshot
The plug-in is hidden by default, if you need to enable the following configuration playerConfig
const player = new Player({
...,
screenShot: true //Show screenshot icon
})
// OR
const player = new Player({
...,
screenShot: {
disable: false
} //Show screenshot icon
})
注意
Be sure to configure the crossOrigin for the player in advance, otherwise canvas toDataURL will trigger an error:
"Uncaught SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': tainted canvases may not be exported."
config
position
@type:Stringdefault:POSITIONS.ROOT_RIGHTFor specific enumeration values, please see plugin-positions
index
@type:Numberdefault:6
quality
@type:Numberdefault:0.92description: quality of the generated pictures,default is 0.92
type
@type:Stringdefault:image/pngdescription: format of picture,default isimage/png
format
@type:Stringdefault:.pngdescription: Picture storage format, default.png
width
@type:Numberdefault:600description: Picture width
height
@type:Numberdefault:337description: Picture height
disable:
@type:Booleandefault:falsedescription: whether to disable
API
shot(width, height, option)
@desc: screenshot@param:{ Number } widthscreenshot width@param:{ Number } heightscreenshot height@param:{ {quality: Number, type: String} } option, default is{ quality: 0.92, type: 'image/png' }@return:Promise<string>
saveScreenShot(data, filename)
@desc: download image@param:{ String } dataimage url, base64 or url string@param:{ String } filenamePicture name
events
Events.SCREEN_SHOT
- value:
screenShot - Trigger Timing: Click the screenshot button and the screenshot is successful
const player = new Player({
...
})
player.on(Events.SCREEN_SHOT, (url)) => {
console.log('screen shot success')
})