stream-example.html 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta name="viewport" content="width=320, initial-scale=1"/>
  5. <title>jsmpeg streaming</title>
  6. <style type="text/css">
  7. body {
  8. background: #333;
  9. text-align: center;
  10. margin-top: 10%;
  11. }
  12. #videoCanvas {
  13. /* Always stretch the canvas to 640x480, regardless of its
  14. internal size. */
  15. width: 640px;
  16. height: 480px;
  17. }
  18. </style>
  19. </head>
  20. <body>
  21. <!-- The Canvas size specified here is the "initial" internal resolution. jsmpeg will
  22. change this internal resolution to whatever the source provides. The size the
  23. canvas is displayed on the website is dictated by the CSS style.
  24. -->
  25. <canvas id="videoCanvas" width="640" height="480">
  26. <p>
  27. Please use a browser that supports the Canvas Element, like
  28. <a href="http://www.google.com/chrome">Chrome</a>,
  29. <a href="http://www.mozilla.com/firefox/">Firefox</a>,
  30. <a href="http://www.apple.com/safari/">Safari</a> or Internet Explorer 10
  31. </p>
  32. </canvas>
  33. <script type="text/javascript" src="jsmpg.js"></script>
  34. <script type="text/javascript">
  35. // Show loading notice
  36. var canvas = document.getElementById('videoCanvas');
  37. var ctx = canvas.getContext('2d');
  38. ctx.fillStyle = '#444';
  39. ctx.fillText('Loading...', canvas.width/2-30, canvas.height/3);
  40. // Setup the WebSocket connection and start the player
  41. var client = new WebSocket( 'ws://example.com:8084/' );
  42. var player = new jsmpeg(client, {canvas:canvas});
  43. </script>
  44. </body>
  45. </html>