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