index.html 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>liveplayer</title>
  5. <meta charset="utf-8">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  7. <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
  8. </head>
  9. <body style="margin:0">
  10. <!--多清晰度播放示例-->
  11. <!-- <live-player video-url="http://192.168.1.11:10080/fvod/GTUGsiqig/video.m3u8" show-custom-button="true" autoplay="true" aspect="16:9" resolution="yh,fhd,hd,sd" resolutiondefault="fhd"></live-player> -->
  12. <!--HTTP-FLV直播播放示例-->
  13. <!-- <live-player video-url="http://192.168.1.11:10080/flv/vlive/68i3az6mg.flv" live="true" aspect="fullscreen"></live-player> -->
  14. <!--RTMP播放示例-->
  15. <!-- <live-player video-url="rtmp://192.168.1.11:10085/vlive/_9VKyi3mg" live="true" aspect="fullscreen"></live-player> -->
  16. <!--M3U8播放示例-->
  17. <!-- <live-player video-url="http://192.168.1.11:10080/vhls/_9VKyi3mg/_9VKyi3mg_live.m3u8" live="true" aspect="16:9"></live-player> -->
  18. <!--mp4播放示例-->
  19. <!-- <live-player video-url="http://192.168.1.11:10080/vod/download/mwoDv_iWR" muted="true" aspect="16:9"></live-player> -->
  20. <!-- <live-player id="player01" video-url="http://192.168.2.135:10080/vhls/0XpHAMvWR/0XpHAMvWR_live.m3u8" live="true" aspect="16:9" stretch="true">
  21. <div style="position:absolute;left:15px;top:15px;color:#FFF;">自定义叠加层</div>
  22. </live-player> -->
  23. <!-- <live-player video-url="http://192.168.2.135:10080/flv/hls/ZJ9rizvZg.flv" live="true" aspect="16:9" stretch="true"></live-player> -->
  24. <script>
  25. window.onload = function () {
  26. // 页面加载完成以后执行
  27. //--------------------JavaScript 交互示例, 当前示例页面放置到web容器里通过http请求访问页面--------------------
  28. // var player = document.getElementById('player01');
  29. // player.addEventListener('snapOutside', function(evt) {
  30. // console.log('获取快照 base64 数据', evt.detail[0]);
  31. // });
  32. // player.addEventListener('fullscreenchange', function() { // use @fullscreenchange.native in vue
  33. // console.log('fullscreenchange', player.getVueInstance().isFullscreen());
  34. // });
  35. // setTimeout(function() {
  36. // console.log("快照, 回调 snapOutside...");
  37. // player.getVueInstance().snap();
  38. // console.log("静音...");
  39. // player.getVueInstance().setMuted(true);
  40. // console.log("静音状态: " + player.getVueInstance().getMuted());
  41. // console.log("暂停...");
  42. // player.getVueInstance().pause();
  43. // console.log("暂停状态: " + player.getVueInstance().paused());
  44. // console.log("全屏状态: " + player.getVueInstance().isFullscreen());
  45. // //触发全屏, 需要放置到交互事件回调中
  46. // //btn.onclick = () => { player.getVueInstance().requestFullscreen(); }
  47. // player.getVueInstance().setMuted(false);
  48. // console.log("音量: " + player.getVueInstance().getVolume());
  49. // player.getVueInstance().setVolume(0.5);
  50. // console.log("音量1: " + player.getVueInstance().getVolume());
  51. // player.getVueInstance().setVolume(0.3);
  52. // console.log("音量2: " + player.getVueInstance().getVolume());
  53. // }, 3000);
  54. // setTimeout(function() {
  55. // console.log("放音...");
  56. // player.getVueInstance().setMuted(false);
  57. // console.log("静音状态: " + player.getVueInstance().getMuted());
  58. // console.log("播放...");
  59. // player.getVueInstance().play();
  60. // console.log("暂停状态: " + player.getVueInstance().paused());
  61. // }, 6000);
  62. // setTimeout(function() {
  63. // console.log("切换媒体源...");
  64. // player.setAttribute("video-url", "rtmp://live.hkstv.hk.lxdns.com/live/hks2");
  65. // }, 9000);
  66. //--------------------常见问题--------------------
  67. //1、提示: TypeError: The element or ID supplied is not valid. (videojs)
  68. //检查 video-url 设置的播放地址 是否有效(可以用 VLC 播放尝试)
  69. //2、提示:Access to XMLHttpRequest at ... from origin .... has been blocked by CORS policy
  70. //检查 video-url 设置的播放地址 是否允许跨域访问
  71. //3、设置为 aspect='fullscreen'时,父级元素加上 position: relative
  72. }
  73. </script>
  74. <script src="liveplayer-element.min.js"></script></body>
  75. </html>