embedded.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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="../script/jquery.min.js"></script>
  9. <script src="../script/ao_module.js"></script>
  10. <script src="script/DPlayer.min.js"></script>
  11. <link rel="manifest" href="manifest.json">
  12. <style>
  13. html, body{
  14. height: 100% !important;
  15. }
  16. body{
  17. background-color: black;
  18. border: 0px;
  19. padding: 0px;
  20. margin: 0px;
  21. overflow:hidden;
  22. }
  23. #dplayer{
  24. height:100% !important;
  25. }
  26. </style>
  27. </head>
  28. <body>
  29. <div id="dplayer"></div>
  30. <script>
  31. //Check if there are another instant running. If yes, replace that another instance URL
  32. if (ao_module_virtualDesktop){
  33. //If in ao_module mode, try to make this windows the only instance
  34. if (!ao_module_makeSingleInstance()){
  35. initPlayback();
  36. }
  37. }else{
  38. initPlayback();
  39. }
  40. //Load global vol from localStorage
  41. var defaultVol = localStorage.getItem("global_volume");
  42. if (defaultVol == null || defaultVol == "" || defaultVol == undefined){
  43. defaultVol = 0.4;
  44. }
  45. function initPlayback(){
  46. //Get file playback info from hash
  47. var playbackFile = ao_module_loadInputFiles();
  48. //Only handle one file
  49. playbackFile = playbackFile[0];
  50. if (playbackFile == null){
  51. return
  52. }
  53. //Update title name
  54. ao_module_setWindowTitle("Video - " + playbackFile.filename);
  55. setTimeout(function(){
  56. updatePlayerSize();
  57. },500);
  58. //Check if this is a transcode file
  59. let fileExt = playbackFile.filename.split(".").pop();
  60. let videoURL = '../media?file=' + encodeURIComponent(playbackFile.filepath);
  61. if (fileExt == "avi" || fileExt == "mkv" || fileExt == "rmvb"){
  62. //transcode
  63. videoURL = '../media/transcode?file=' + encodeURIComponent(playbackFile.filepath);
  64. }
  65. //Set player property
  66. const dp = new DPlayer({
  67. container: document.getElementById('dplayer'),
  68. screenshot: true,
  69. autoplay: true,
  70. volume: parseFloat(defaultVol),
  71. video: {
  72. url: videoURL
  73. },
  74. contextmenu: [
  75. {
  76. text: 'Download',
  77. link: '../media/download?file=' + encodeURIComponent(playbackFile.filepath),
  78. }
  79. ],
  80. });
  81. dp.on("volumechange",function(){
  82. var newVol = dp.volume();
  83. if (localStorage){
  84. localStorage.setItem("global_volume",newVol);
  85. }
  86. });
  87. $(window).on("resize",function(){
  88. updatePlayerSize();
  89. });
  90. }
  91. function updatePlayerSize(){
  92. if ($("#dplayer").height() < window.innerHeight){
  93. var topm = (window.innerHeight - $("#dplayer").height()) / 2
  94. $("#dplayer").css("margin-top",topm);
  95. $("#dplayer").css("height","auto");
  96. }
  97. }
  98. </script>
  99. </body>
  100. </html>