Player.html 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>{{ escape(PageTitle) }}</title>
  6. <meta name="referrer" content="no-referrer">
  7. <link rel="stylesheet" type="text/css" href="{{ escape(SubPath) }}{{ static_url("css/video-js.min.css") }}">
  8. <style type="text/css">
  9. * {margin: 0; padding: 0;}
  10. html, body {height: 100%; overflow: hidden;}
  11. body {text-align: center; background: black;}
  12. video:focus {outline: none;}
  13. .wrapper {width: 100%; margin: auto; height: 100%; text-align: center;}
  14. .video-js {width: 100% !important; height: 100% !important; position: relative !important;}
  15. .vjs-big-play-button {margin-top: -130px !important;}
  16. @media (max-width: 1200px) {body{background: #1d1d1d;}}
  17. </style>
  18. </head>
  19. <body>
  20. <div class="wrapper">
  21. <video id=player width=960 height=540 class="video-js vjs-default-skin vjs-big-play-centered" controls>
  22. <source src="data:application/vnd.apple.mpegurl;base64,{{ escape(PageData) }}" type="application/vnd.apple.mpegurl">
  23. </video>
  24. </div>
  25. <script src="{{ escape(SubPath) }}{{ static_url("js/video.min.js") }}"></script>
  26. <script src="{{ escape(SubPath) }}{{ static_url("js/videojs.hotkeys.min.js") }}"></script>
  27. <script>
  28. let url = window.location.href, textTracks = document.getElementById('textTracks'), webvtt = url.substring(url, url.lastIndexOf(".")) + '.vtt'
  29. var player = videojs('player', {
  30. html5: {
  31. hls: {
  32. overrideNative: !videojs.browser.IS_SAFARI,
  33. }
  34. },
  35. playbackRates: [0.5, 0.75, 1, 1.25, 1.5, 2]
  36. });
  37. videojs.Hls.xhr.beforeRequest = function(options) {
  38. if (options.headers) {
  39. delete options.headers.Range;
  40. }
  41. return options;
  42. }
  43. player.ready(function () {
  44. this.hotkeys({
  45. seekStep: 5,
  46. volumeStep: 0.1,
  47. enableModifiersForNumbers: false
  48. });
  49. if (checkExists(webvtt)) {
  50. player.addRemoteTextTrack({kind: "captions", label: "subtitles on", mode: "showing", src: webvtt});
  51. textSetting = player.textTrackSettings.getValues();
  52. textSetting.backgroundOpacity = "0";
  53. textSetting.windowOpacity = "0";
  54. textSetting.textOpacity = "1";
  55. player.textTrackSettings.setValues(textSetting);
  56. };
  57. });
  58. function checkExists(url) {
  59. let http = new XMLHttpRequest()
  60. http.open("GET", url, false);
  61. http.send();
  62. if (http.readyState == 4) {
  63. if (http.status == 200){
  64. return true
  65. }else{
  66. return false
  67. }
  68. }else{
  69. return false
  70. }
  71. }
  72. </script>
  73. </body>
  74. </html>