Reputation: 26601
I've created a C# program which captures the screen as a Jpeg image and saves it to a file. Then using HTML5's Canvas, I'm using this code to pull in the image and display it, updating every 8 milliseconds so it looks like a video.
<html>
<head>
<script type="application/javascript">
function draw() {
var c=document.getElementById("myCanvas");
var cxt=c.getContext("2d");
var img=new Image();
img.src="C://wamp/www/test.jpg?" + new Date().getTime();
img.onload = function() {
cxt.drawImage(img, 0, 0);
};
}
function start() {
setInterval("draw()",15);
}
</script>
</head>
<body onLoad="start()">
<canvas id="myCanvas" width="1024" height="720"></canvas>
</body>
</html>
Doing this locally gives a good picture (a bit choppy, but still good) but doing it over the internet is useless. Is there a way to stream the image straight from the C# program instead of using a file? Would that update it quick enough for a good picture? Or shall I compress the image in the C# program? Just looking for any pointers of how to make this work. Thanks for the help! :)
Upvotes: 0
Views: 1422
Reputation: 5681
If you can manage to code the delivery-method, it shouldn't be any worse than attaching a html5-video element to a endpoint in your app :)
But it might involve transcoding jpeg-images to h264 on the fly ;)
Upvotes: 1