Simple SVG Streaming Client
Posted by Anonymous on May Wed 30th 11:20 PM - Never Expires| View : 57Syntax: HTML4STRICT
1876 characters | 53 lines | 1.83 KB
- <!doctype html>
- <html>
- <head>
- <script>
- function start_stream() {
- stream_sink = $("#stream_sink")[0].getContext("2d");
- stream_source = new Image();
- stream_source.onload = function() {
- clear_sink();
- stream_sink.drawImage(stream_source, 0, 0, stream_source.width, stream_source.height);
- };
- return setInterval(update_stream, (1000 / $("#fps").val()));
- }
- function clear_sink() {
- stream_sink.fillStyle = "#454A41";
- stream_sink.fillRect(0, 0, 640, 480);
- }
- function update_sink(data, text_status, jqXHR) {
- stream_source.src = data;
- }
- function update_stream() {
- $.ajax({
- url: $("#stream").val(),
- success: update_sink,
- dataType: "text"});
- }
- $(function(){
- interval_id = start_stream();
- $("#fps").change(function() {
- clearInterval(interval_id)
- interval_id = setInterval(update_stream, (1000 / $("#fps").val()));
- });
- });
- </script>
- </head>
- <body>
- <section>
- <canvas id="stream_sink" width="640" height="480"></canvas>
- <form>
- </form>
- </section>
- </body>
- </html>
