embedded.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. //Set player property
  59. const dp = new DPlayer({
  60. container: document.getElementById('dplayer'),
  61. screenshot: true,
  62. autoplay: true,
  63. volume: parseFloat(defaultVol),
  64. video: {
  65. url: '../media?file=' + encodeURIComponent(playbackFile.filepath)
  66. },
  67. contextmenu: [
  68. {
  69. text: 'Download',
  70. link: '../media/download?file=' + encodeURIComponent(playbackFile.filepath),
  71. }
  72. ],
  73. });
  74. dp.on("volumechange",function(){
  75. var newVol = dp.volume();
  76. if (localStorage){
  77. localStorage.setItem("global_volume",newVol);
  78. }
  79. });
  80. $(window).on("resize",function(){
  81. updatePlayerSize();
  82. });
  83. }
  84. function updatePlayerSize(){
  85. if ($("#dplayer").height() < window.innerHeight){
  86. var topm = (window.innerHeight - $("#dplayer").height()) / 2
  87. $("#dplayer").css("margin-top",topm);
  88. $("#dplayer").css("height","auto");
  89. }
  90. }
  91. </script>
  92. </body>
  93. </html>