When using <video id="videoID"> </video>
(HTML),
you can use canvas = document.getElementById('canvas')
in the script (Javascript)
and videoID.play()
or videoID.pause()
.
If my video is streaming from a URL (as webcams do) as an
<img src="http://ip_address/stream">
tag, I can't use the .play()
or .pause()
functions.
Can I still use:
canvas = document.getElementById('canvas');
var context = acontainer.getContext('2d');
context.drawImage(acontainer, 0, 0, width, height);
var data = acontainer.toDataURL('image/jpeg');
photo.setAttribute('src', data);
The goal is to get a picture of the video stream when I click - so I have a mouse click event that does the above.
How can I do this?
More info: This page has URL http://ip_address
and video stream has URL http://ip_address/stream
. The video stream is <img>
-lots of jpeg images being streamed- within a <div>
container, e.g.
Code looks like-
<!DOCTYPE html>
<html>
<head>
...
<style>
...
</style>
</head>
<body>
<div id="container">
<img src=...>
</div>
<script>
container.addEventListener("click", function(element){}, false);
...
</script>
</body>
</html>
EDIT: This question is not a duplicate as I'm not asking how to stream to a html canvas. Rather, I already have a stream displaying in a container and I want to take a photo of it and have it appear in a canvas - so the stream and photo appear on the same page.