demo-hls.html 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  6. <meta name="renderer" content="webkit">
  7. <title>HLS播放协议</title>
  8. <style>
  9. body {
  10. margin: 0;
  11. }
  12. #myPlayer {
  13. max-width: 600px;
  14. width: 600px;
  15. }
  16. </style>
  17. </head>
  18. <script>
  19. </script>
  20. <body>
  21. <script src="../ezuikit.js"></script>
  22. <script src="../js/jquery.min.js"></script>
  23. <button id="start">开始播放</button>
  24. <button id="pause">暂停播放</button>
  25. <button id="stop">停止播放</button>
  26. <video
  27. id="myPlayer"
  28. poster=""
  29. controls
  30. playsInline
  31. webkit-playsinline
  32. >
  33. <source src="http://hls.open.ys7.com/openlive/0209eadc8aa84aec88b441519b021d7f.m3u8" type="application/x-mpegURL"/>
  34. </video>
  35. <script>
  36. var player = new EZuikit.EZUIPlayer('myPlayer');
  37. // 日志
  38. player.on('log', log);
  39. function log(str) {
  40. var div = document.createElement('DIV');
  41. div.innerHTML = (new Date()).Format('yyyy-MM-dd hh:mm:ss.S') + JSON.stringify(str);
  42. document.body.appendChild(div);
  43. }
  44. $("#start").click(function () {
  45. console.log("开始播放");
  46. player.play();
  47. });
  48. $("#pause").click(function () {
  49. console.log("暂停播放");
  50. player.pause();
  51. });
  52. $("#stop").click(function () {
  53. console.log("结束播放", player);
  54. player.stop();
  55. });
  56. </script>
  57. </body>
  58. </html>