MCPcopy
hub / github.com/DIYgod/DPlayer / initScreenshotButton

Method initScreenshotButton

src/js/controller.js:232–255  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

230 }
231
232 initScreenshotButton() {
233 if (this.player.options.screenshot) {
234 this.player.template.camareButton.addEventListener('click', () => {
235 const canvas = document.createElement('canvas');
236 canvas.width = this.player.video.videoWidth;
237 canvas.height = this.player.video.videoHeight;
238 canvas.getContext('2d').drawImage(this.player.video, 0, 0, canvas.width, canvas.height);
239
240 let dataURL;
241 canvas.toBlob((blob) => {
242 dataURL = URL.createObjectURL(blob);
243 const link = document.createElement('a');
244 link.href = dataURL;
245 link.download = 'DPlayer.png';
246 link.style.display = 'none';
247 document.body.appendChild(link);
248 link.click();
249 document.body.removeChild(link);
250 URL.revokeObjectURL(dataURL);
251 this.player.events.trigger('screenshot', dataURL);
252 });
253 });
254 }
255 }
256
257 initAirplayButton() {
258 if (this.player.options.airplay) {

Callers 1

constructorMethod · 0.95

Calls 1

triggerMethod · 0.80

Tested by

no test coverage detected