西瓜播放器 HTML5 video video.js 播放器 HTML5播放器 mp4 hls hls.js flv flv.js dash dash.js 无缝切换

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: String
  • default: POSITIONS.ROOT_RIGHTFor specific enumeration values, please see plugin-positions

index

  • @type: Number
  • default: 6

quality

  • @type: Number
  • default: 0.92
  • description: quality of the generated pictures,default is 0.92

type

  • @type: String
  • default: image/png
  • description: format of picture,default is image/png

format

  • @type: String
  • default: .png
  • description: Picture storage format, default .png

width

  • @type: Number
  • default: 600
  • description: Picture width

height

  • @type: Number
  • default: 337
  • description: Picture height

disable:

  • @type: Boolean
  • default: false
  • description: whether to disable

API

shot(width, height, option)

  • @desc: screenshot
  • @param: { Number } width screenshot width
  • @param: { Number } height screenshot 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 } data image url, base64 or url string
  • @param: { String } filename Picture 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')
})