video.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <!DOCTYPE html>
  2. <meta name="apple-mobile-web-app-capable" content="yes" />
  3. <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>
  4. <html>
  5. <head>
  6. <meta charset="UTF-8">
  7. <meta name="theme-color" content="#4b75ff">
  8. <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  9. <script src="script/DPlayer.min.js"></script>
  10. <style>
  11. html, body{
  12. height: 100% !important;
  13. }
  14. body{
  15. background-color: black;
  16. border: 0px;
  17. padding: 0px;
  18. margin: 0px;
  19. overflow:hidden;
  20. }
  21. #dplayer{
  22. height:100% !important;
  23. }
  24. </style>
  25. </head>
  26. <body>
  27. <div id="dplayer"></div>
  28. <script>
  29. function loadInputFiles(){
  30. try{
  31. if (window.location.hash.length == 0){
  32. return null;
  33. }
  34. var inputFileInfo = window.location.hash.substring(1,window.location.hash.length);
  35. inputFileInfo = JSON.parse(decodeURIComponent(inputFileInfo));
  36. if (inputFileInfo.length == 0){
  37. return null;
  38. }
  39. return inputFileInfo
  40. }catch{
  41. return null;
  42. }
  43. }
  44. initPlayback();
  45. //Load global vol from localStorage
  46. var defaultVol = localStorage.getItem("global_volume");
  47. if (defaultVol == null || defaultVol == "" || defaultVol == undefined){
  48. defaultVol = 0.4;
  49. }
  50. function initPlayback(){
  51. //Get file playback info from hash
  52. var playbackFile = loadInputFiles();
  53. //Only handle one file
  54. playbackFile = playbackFile;
  55. if (playbackFile == null){
  56. return
  57. }
  58. //Update title name
  59. document.title = ("Video - " + playbackFile.filename);
  60. setTimeout(function(){
  61. updatePlayerSize();
  62. },500);
  63. //Set player property
  64. const dp = new DPlayer({
  65. container: document.getElementById('dplayer'),
  66. screenshot: true,
  67. autoplay: true,
  68. volume: parseFloat(defaultVol),
  69. video: {
  70. url: '/api/fs/download?preview=true&file=' + encodeURIComponent(playbackFile.filepath)
  71. }
  72. });
  73. dp.on("volumechange",function(){
  74. var newVol = dp.volume();
  75. if (localStorage){
  76. localStorage.setItem("global_volume",newVol);
  77. }
  78. });
  79. $(window).on("resize",function(){
  80. updatePlayerSize();
  81. });
  82. }
  83. function updatePlayerSize(){
  84. if ($("#dplayer").height() < window.innerHeight){
  85. var topm = (window.innerHeight - $("#dplayer").height()) / 2
  86. $("#dplayer").css("margin-top",topm);
  87. $("#dplayer").css("height","auto");
  88. }
  89. }
  90. </script>
  91. </body>
  92. </html>