video.html 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. <script type="text/javascript" src="liveplayer-element.min.js"></script>
  9. <script type="text/javascript">
  10. window.onload = function() {
  11. }
  12. window.addEventListener("message", function(event) {
  13. var data = event.data;
  14. switch (data.cmd) {
  15. case 'switchUrl':
  16. // 处理业务逻辑
  17. console.log("收到消息:"+JSON.stringify(data.params));
  18. var player = document.getElementById('player01');
  19. player.setAttribute("video-url",data.params["path"]);
  20. if(data.params['live'])
  21. {
  22. player.setAttribute('live',true);
  23. }
  24. else
  25. {
  26. player.setAttribute('live',false);
  27. }
  28. break;
  29. }
  30. });
  31. function getQueryVariable(variable) {
  32. var query = window.location.search.substring(1);
  33. var vars = query.split("&");
  34. for (var i = 0; i < vars.length; i++) {
  35. var pair = vars[i].split("=");
  36. if (pair[0] == variable) {
  37. return pair[1];
  38. }
  39. }
  40. return (false);
  41. }
  42. </script>
  43. </head>
  44. <body>
  45. <live-player id="player01" live="true" stretch="true" show-custom-button="false" autoplay>
  46. </live-player>
  47. <script>
  48. var videoPath = decodeURIComponent(getQueryVariable("url"));
  49. console.log('播放地址:' + videoPath);
  50. var player = document.getElementById('player01');
  51. player.setAttribute("video-url", videoPath);
  52. </script>
  53. </body>
  54. </html>