A imagem HTML5 Canvas draw com a fonte de vídeo não funciona no Android
Estou tentando usar telasdrawImage
método com fonte de vídeo, mas não está funcionando no Android 4.4.2, testado com o navegador Chrome.
Aqui está o meu código:
$(function() {
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var video = document.getElementById('video');
var videoWidth;
var videoHeight;
var paused = false;
canvas.addEventListener('click', function() {
if (paused) {
video.play();
} else {
video.pause();
}
paused = !paused;
});
video.addEventListener("loadedmetadata", function() {
videoWidth = this.videoWidth || this.width;
videoHeight = this.videoHeight || this.height;
canvas.width = videoWidth;
canvas.height = videoHeight;
}, false);
video.addEventListener('play', function() {
var $this = this; // cache
(function loop() {
if ( ! $this.paused && ! $this.ended ) {
drawImage($this);
requestAnimationFrame(loop);
// setTimeout(loop, 1000 / 25); // drawing at 25 fps
}
})();
}, 0);
function drawImage(frame) {
ctx.drawImage(frame, 0, 0);
// ctx.clearRect ( 0 , 0 , canvas.width, canvas.height );
}
});
Violino: http://jsfiddle.net/h1hjp0Lp/
Existe uma maneira de fazê-lo funcionar com dispositivos Android e iOS também?