Zrzut bieżącej klatki wideo
Akcja paska narzędzi: zapisuje bieżącą klatkę odtwarzanego wideo jako plik PNG.
Kod do skopiowania
// Toolbar action: capture the current frame of the playing video.
(function () {
var videos = Array.prototype.slice.call(document.querySelectorAll('video'));
videos.sort(function (a, b) {
return (b.clientWidth * b.clientHeight) - (a.clientWidth * a.clientHeight);
});
var v = videos[0];
if (!v || !v.videoWidth) { alert('No playable video found.'); return; }
try {
var c = document.createElement('canvas');
c.width = v.videoWidth;
c.height = v.videoHeight;
c.getContext('2d').drawImage(v, 0, 0, c.width, c.height);
var a = document.createElement('a');
a.href = c.toDataURL('image/png');
a.download = 'video-frame-' + Math.round(v.currentTime) + 's.png';
document.body.appendChild(a);
a.click();
a.remove();
} catch (e) {
alert('Could not capture this frame: ' + e.message);
}
})();
Jak użyć tego przykładu
- Skopiuj kod przyciskiem powyżej.
- Zainstaluj JustZix (2 minuty) i otwórz wtyczkę na docelowej stronie.
- Dodaj nową regułę dopasowaną do tej strony.
- Włącz panel akcji, dodaj przycisk w zakładce Akcje i wklej w nim kod — odpalisz go jednym kliknięciem.
Oceń ten przykład
Brak ocen — oceń jako pierwszy.