So here is what I am trying to do: I want to load a video into a video element, but not play in the “normal” way. Using the time interval calculated according to the frame rate in the movie, I want at each iteration
and. Manually move the video one “frame” (or as close to it as possible).
B. Draw this frame on canvas.
Thus, the video is “played” inside the canvas.
Here is the code:
<video width="400" height="224" id="mainVideo" src="urltovideo.mp4" type="video/mp4"></video>
<canvas width="400" height="224" id="videoCanvas"></canvas>
<script type="text/javascript">
var videoDom = document.querySelector("#mainVideo");
var videoCanvas = document.querySelector("#videoCanvas");
var videoCtx = null;
var interval = null;
videoDom.addEventListener('canplay',function() {
interval = setInterval(function() { doVideoCanvas(); }, 41.66);
});
videoDom.addEventListener('loadeddata',function() {
videoCtx = videoCanvas.getContext('2d');
});
function doVideoCanvas() {
videoCtx.drawImage(videoDom,0,0);
videoDom.currentTime += 0.0416;
}
</script>
This works fine in Google Chrome, but it doesn't work in Iphone Safari;
Video frames are not painted at all on the canvas.
I made sure that:
- The video events that I connected to are triggered (there were "warnings" and they were shown).
- ( '
fillRect' ).
[ drawImage - ]
drawImage , Iphone Safari...?
, Iphone :
currentTime ( ). , - " ", , . , , - , ;
, Safari IOS. video.play(), autoplay, , . " " , ( , IPhone).
- currentTime . . html - , . ( Google Chrome, , , ) - iphone, , 2-3 . , , , , IPhone.
" " :)
- - ( "" ). , ?
Iphone 3GS ( 3G Wi-Fi) Iphone 4, IOS 5, , .