audio.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  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=0.6, maximum-scale=0.6"/>
  4. <html>
  5. <head>
  6. <meta charset="UTF-8">
  7. <script type='text/javascript' charset='utf-8'>
  8. </script>
  9. <title>ArOZ Onlineβ</title>
  10. <link rel="stylesheet" href="../../script/semantic/semantic.min.css">
  11. <script src="../../script/semantic/semantic.min.js"></script>
  12. <script src="../../script/jquery.min.js"></script>
  13. <script src="../../script/ao_module.js"></script>
  14. <style>
  15. .transparent{
  16. background-color:rgba(255, 255, 255, 0) !important;
  17. border:1px solid transparent;
  18. }
  19. .seventytransparent{
  20. background-color:rgba(255, 255, 255, 0.7) !important;
  21. border:1px solid transparent;
  22. }
  23. body {
  24. background: rgba(255,255,255,1);
  25. }
  26. </style>
  27. </head>
  28. <body>
  29. <div >
  30. <!-- Audio Control System with no HTML5 Audio Attribute-->
  31. <div>
  32. <div id="audio_attr"style="display:none;">
  33. <audio id="player" controls autoplay>
  34. <source src="" type="audio/mpeg">
  35. Your browser does not support the audio element.
  36. </audio>
  37. </div>
  38. <div id="YamiPlayer" class="content transparent" style="top:0;">
  39. <div id="songname" class="ui top attached segment" style="border: 1px solid transparent;">
  40. <i class="music icon"></i>
  41. </div>
  42. <div id="progressbardiv" class="ui attached progress" style="height: 1em; background-color: #eeeeee;">
  43. <div id="audioprogress" class="bar" style="min-width: 0px; width: 0%; height: 1em;"></div>
  44. </div>
  45. <div style="background-color: white; margin-top: 5px;">
  46. <div style="display: flex; flex-wrap: nowrap;">
  47. <div class="ui icon buttons" style="margin-left: 12px;">
  48. <!-- <button class="ui disabled button" onclick="PreviousSong()"><i class="step backward icon"></i></button> -->
  49. <button class="ui basic black button" onclick="playbtn()"><i id='playbtn' class="pause icon"></i></button>
  50. <!-- <button class="ui disabled button" onclick="NextSong()"><i class="step forward icon"></i></button> -->
  51. <button class="ui basic black button" onclick="stopbtn()"><i class="stop icon"></i></button>
  52. <button class="ui basic black button" onclick="volDown()"><i class="volume down icon"></i></button>
  53. <button class="ui basic black button" onclick="volUp()"><i class="volume up icon"></i></button>
  54. <button class="ui basic black button" onclick="repeatmode()"><i class="repeat icon"></i></button>
  55. </div>
  56. <div style="display: flex; flex-wrap: nowrap; margin-left: 1em; padding-top: 8px;">
  57. <div>
  58. <i class="volume off icon"></i><span id="voldis">100%</span>
  59. </div>
  60. <div style="margin-left: 0.5em;">
  61. <i class="time icon"></i><span id="timecode">0:00/0:00</span>
  62. </div>
  63. <div style="margin-left: 0.5em;">
  64. <i class="repeat icon"></i><span id="repmode">Single</span>
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. <!-- <button class="ts button" onclick="Show_Audio_Attrubute()">Show HTML5 Attrubute</button> -->
  70. </div>
  71. </div>
  72. </div>
  73. <script>
  74. /*
  75. ArOZ Online Beta Audio Module Embedded Player
  76. Migrated to arozos 1.105 by tobychui
  77. Updated UI design in arozos v1.121 by tobychui
  78. */
  79. //ArOZ Online BETA control system
  80. var pwa = false;
  81. var inVDI = true;
  82. var embedded = true;
  83. var downloadmode = false;
  84. var lastactiveid = -1;
  85. var RepeatMode = 2;
  86. var extDiskAccessAPI="../../media/?file=";
  87. ////////////////////////////
  88. $( document ).ready(function() {
  89. //Set the default path selector value
  90. if (pwa){
  91. $(".pwa").each(function(){
  92. $(this).addClass('disabled');
  93. });
  94. $(".pwahide").each(function(){
  95. $(this).hide();
  96. });
  97. }
  98. var is_safari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  99. if (is_safari){
  100. //This is added to fix some glitch on Safari tested on a Mac Machine
  101. $("body").css("background-color:white;")
  102. }
  103. //Update functions called following the AOB 11-8-2018 updates
  104. //Now, the embedded windows can ask for resize properties and icon from the system
  105. //If it is currently in VDI, force the current window size and resize properties
  106. var windowID = $(window.frameElement).parent().attr("id");
  107. ao_module_setFixedWindowSize();
  108. if (inVDI){
  109. //It is currently in Virtual Desktop Mode, make it semi-transparent!
  110. //$('body').css('background','rgba(255,255,255,0.7)');
  111. setInterval(function() {
  112. GvolDisplay();
  113. },1000);
  114. if ($("#backBtn").length > 0){
  115. $("#backBtn").attr("href","");
  116. }
  117. var windowID = $(window.frameElement).parent().attr("id");
  118. }
  119. $("#searchbar").hide();
  120. $('#downloadmode_reminder').hide();
  121. $('#playbtn').attr('class', 'play icon');
  122. //Load the global volume from the stored data
  123. var globalvol = localStorage.getItem("global_volume");
  124. var player = document.getElementById("player");
  125. //console.log("Global Volume" + globalvol.toString());
  126. if (!globalvol){
  127. globalvol = 0.6;
  128. }
  129. player.volume = parseFloat(globalvol);
  130. $('#voldis').html(" " + (Math.round(player.volume * 100)).toString() + "%");
  131. //Load the repeat mode from stored data
  132. var repmode = localStorage.getItem("repeat_mode");
  133. if (repmode == 0){
  134. //0
  135. $('#repmode').html(' Single');
  136. RepeatMode = 0;
  137. }else if (repmode == 1){
  138. //1
  139. $('#repmode').html(' ALL');
  140. RepeatMode = 1;
  141. }else{
  142. //2
  143. $('#repmode').html(' None');
  144. RepeatMode = 2;
  145. }
  146. //console.log(songlist);
  147. if (embedded == true && repmode == 1){
  148. //Now allow all mode in embedded
  149. $('#repmode').html(' None');
  150. RepeatMode = 2;
  151. }
  152. //Read the file input
  153. var inputFiles = ao_module_loadInputFiles();
  154. if (inputFiles.length > 0){
  155. inputFiles = inputFiles[0];
  156. PlaySong(inputFiles.filepath, inputFiles.filename, "");
  157. }
  158. });
  159. //On Pause or Play using Android notification on Firefox / Chrome
  160. var aud = document.getElementById("player");
  161. aud.onpause = function() {
  162. //Paused by the user on notification
  163. $('#playbtn').attr('class', 'play icon');
  164. };
  165. aud.onplay = function() {
  166. //Play by the user on notification
  167. $('#playbtn').attr('class', 'pause icon');
  168. };
  169. function GvolDisplay(){
  170. var globalvol = (Math.round(GetStorage('global_volume') * 100)) / 100;
  171. var audio = document.getElementById("player");
  172. audio.volume = globalvol;
  173. $('#voldis').html(" " + (Math.round(audio.volume * 100)).toString() + "%");
  174. }
  175. //These function is for ArOZ Online System quick storage data processing
  176. function CheckStorage(id){
  177. if (typeof(Storage) !== "undefined") {
  178. return true;
  179. } else {
  180. return false;
  181. }
  182. }
  183. function GetStorage(id){
  184. //All data get are string
  185. return localStorage.getItem(id);
  186. }
  187. function SaveStorage(id,value){
  188. localStorage.setItem(id, value);
  189. return true;
  190. }
  191. function toggleSearch(){
  192. //Id of Search Bar: searchbar
  193. if (SearchBarOn){
  194. //Need to close the Search Bar
  195. $("#searchbar").css("display", "none");
  196. SearchBarOn = false;
  197. }else{
  198. $("#searchbar").css("display", "block");
  199. SearchBarOn = true;
  200. $(window).scrollTop(0);
  201. $("#sbinput").focus();
  202. }
  203. }
  204. $('#searchbar').bind("enterKey",function(e){
  205. var keyword = $( "#sbinput" ).val();
  206. if (keyword != ""){
  207. window.location.href = "../Audio/index.php?search=" + keyword;
  208. }else{
  209. window.location.href = "../Audio/";
  210. }
  211. });
  212. $('#searchbar').keyup(function(e){
  213. if(e.keyCode == 13)
  214. {
  215. $(this).trigger("enterKey");
  216. }
  217. });
  218. function toggledownload(){
  219. if (downloadmode == true){
  220. $('#downloadmode_reminder').stop();
  221. $('#sbtext').html('Download Mode Disabled.');
  222. $("#downloadmodeBtn").css("background-color","");
  223. $('#downloadmode_reminder').fadeIn('slow').delay(2000).fadeOut('slow');
  224. downloadmode = false;
  225. }else{
  226. $('#downloadmode_reminder').stop();
  227. $('#sbtext').html('Download Mode Enabled.');
  228. $("#downloadmodeBtn").css("background-color","#b0ffaa");
  229. $('#downloadmode_reminder').fadeIn('slow').delay(2000).fadeOut('slow');
  230. downloadmode = true;
  231. }
  232. }
  233. function getRealID(textid){
  234. return parseInt(textid.replace("AudioID",""));
  235. }
  236. function change(sourceUrl) {
  237. var audio = $("#player");
  238. $("#player").attr("src", "../../media?file=" + sourceUrl);
  239. audio[0].pause();
  240. audio[0].load();//suspends and restores all audio element
  241. //audio[0].play(); changed based on Sprachprofi's comment below
  242. audio[0].oncanplaythrough = audio[0].play();
  243. }
  244. function PlaySong(name,displayname,id){
  245. if (downloadmode == false){
  246. //This operation is for choosing song
  247. $('#songname').html(`<i class="music icon"></i> `+ decodeURIComponent(displayname));
  248. change(name);
  249. playingSong = [name,displayname,id];
  250. //console.log(playingSong);
  251. $('#playbtn').attr('class', 'pause icon');
  252. if (lastactiveid.toString() != id.toString()){
  253. $('#' + lastactiveid).attr('class', 'ts item');
  254. $('#' + id.toString()).attr('class', 'ts item active');
  255. }
  256. lastactiveid = id;
  257. $(document).prop('title', displayname);
  258. //console.log(lastactiveid);
  259. if (inVDI){
  260. //If it is currently in VDI, update the floatWindow title as well
  261. ao_module_setWindowTitle(decodeURIComponent(displayname));
  262. }
  263. }else if (downloadmode == true){
  264. //This operation is for downloading the audio file
  265. saveAs(name,displayname);
  266. }
  267. }
  268. function CheckPlaying(){
  269. var player = document.getElementById('player');
  270. if (player.paused){
  271. //Chrome does not allow instant playing of audio so user have to click the btn themselves.
  272. $('#playbtn').attr('class', 'play icon');
  273. }
  274. }
  275. function NextSong(){
  276. lastactiveid = parseInt(lastactiveid);
  277. if (lastactiveid != "undefined"){
  278. if (lastactiveid < songlist.length - 1){
  279. PlaySong(songlist[lastactiveid + 1][0],songlist[lastactiveid + 1][1],songlist[lastactiveid + 1][2]);
  280. }else{
  281. PlaySong(songlist[0][0],songlist[0][1],songlist[0][2]);
  282. }
  283. }
  284. }
  285. function PreviousSong(){
  286. lastactiveid = parseInt(lastactiveid);
  287. if (lastactiveid != "undefined"){
  288. if (lastactiveid > 0){
  289. PlaySong(songlist[lastactiveid - 1][0],songlist[lastactiveid - 1][1],songlist[lastactiveid - 1][2]);
  290. }
  291. }
  292. }
  293. function saveAs(uri, filename) {
  294. if (extStorageMode){
  295. uri = extDiskAccessAPI + uri + "&mode=download&filename=" + JSON.stringify(filename);
  296. }
  297. var link = document.createElement('a');
  298. if (typeof link.download === 'string') {
  299. document.body.appendChild(link); // Firefox requires the link to be in the body
  300. link.download = filename;
  301. link.href = uri;
  302. link.click();
  303. document.body.removeChild(link); // remove the link when done
  304. } else {
  305. location.replace(uri);
  306. }
  307. }
  308. function Show_Audio_Attrubute(){
  309. $("#audio_attr").fadeIn("slow");
  310. }
  311. function Hide_Audio_Attrubute(){
  312. $("#audio_attr").fadeOut("slow");
  313. }
  314. function repeatmode(){
  315. //This set the repeat mode for the browser reference.
  316. var repmode = localStorage.getItem("repeat_mode");
  317. // 0 = Single Repeat, repeat the same song
  318. // 1 = All Repeat, repeat when it reached the bottom of the list
  319. // 2 = No Repeat, stop after finishing this song.
  320. if (repmode == 0){
  321. //0 -> 1
  322. if (embedded == true){
  323. repmode = 2;
  324. $('#repmode').html(' None');
  325. localStorage.setItem("repeat_mode", 2);
  326. }else{
  327. $('#repmode').html(' ALL');
  328. localStorage.setItem("repeat_mode", 1);
  329. }
  330. }else if (repmode == 1){
  331. //1 -> 2
  332. $('#repmode').html(' None');
  333. localStorage.setItem("repeat_mode", 2);
  334. }else{
  335. //2 -> 0
  336. $('#repmode').html(' Single');
  337. localStorage.setItem("repeat_mode", 0);
  338. }
  339. }
  340. function playbtn(){
  341. if (document.getElementById('player').paused == true){
  342. $('#playbtn').attr('class', 'pause icon');
  343. $('#player').trigger('play');
  344. }else{
  345. $('#playbtn').attr('class', 'play icon');
  346. $('#player').trigger('pause');
  347. }
  348. }
  349. function stopbtn(){
  350. $('#player').trigger('pause');
  351. document.getElementById('player').currentTime = 0;
  352. $('#playbtn').attr('class', 'play icon');
  353. }
  354. $("#progressbardiv").click(function(e){
  355. var parentOffset = $(this).parent().offset();
  356. //or $(this).offset(); if you really just want the current element's offset
  357. var relX = e.pageX - parentOffset.left;
  358. var relY = e.pageY - parentOffset.top;
  359. var divwidth = $(this).parent().width();
  360. var ratio = relX / divwidth;
  361. var player = document.getElementById('player');
  362. var targettime = Math.round(player.duration * ratio);
  363. player.currentTime = parseFloat(targettime);
  364. //console.log(ratio);
  365. });
  366. var player = document.getElementById('player');
  367. //For every time update
  368. player.addEventListener("timeupdate", function() {
  369. var currentTime = player.currentTime;
  370. var duration = player.duration;
  371. $('#timecode').html(" " + FTF(Math.round(currentTime)) + "/" + FTF(Math.round(duration)));
  372. $('#audioprogress').stop(true,true).animate({'width':(currentTime)/duration*100+'%'},0,'linear');
  373. });
  374. //When the audio file is loaded
  375. player.addEventListener("canplay", function() {
  376. //Load the global volume from the stored data
  377. var globalvol = localStorage.getItem("global_volume");
  378. //console.log("Global Volume" + globalvol.toString());
  379. if (!globalvol){
  380. globalvol = 0.6;
  381. }
  382. player.volume = globalvol;
  383. $('#voldis').html(" " + (Math.round(player.volume * 100)).toString() + "%");
  384. //Load the repeat mode from stored data
  385. var repmode = localStorage.getItem("repeat_mode");
  386. if (embedded == true){
  387. if (repmode == 1){
  388. $('#repmode').html(' None');
  389. repmode = 2;
  390. }
  391. }
  392. if (repmode == 0){
  393. //0
  394. $('#repmode').html(' Single');
  395. RepeatMode = 0;
  396. }else if (repmode == 1){
  397. //1
  398. $('#repmode').html(' ALL');
  399. RepeatMode = 1;
  400. }else{
  401. //2
  402. $('#repmode').html(' None');
  403. RepeatMode = 2;
  404. }
  405. });
  406. //Event when the player finished the audio playing
  407. player.addEventListener("ended", function() {
  408. var repmode = localStorage.getItem("repeat_mode");
  409. if (repmode == 0){
  410. //0
  411. $('#repmode').html(' Single');
  412. RepeatMode = 0;
  413. }else if (repmode == 1){
  414. //1
  415. $('#repmode').html(' ALL');
  416. RepeatMode = 1;
  417. }else{
  418. //2
  419. $('#repmode').html(' None');
  420. RepeatMode = 2;
  421. }
  422. if (embedded == true){
  423. if (RepeatMode == 1){
  424. RepeatMode = 2;
  425. $('#repmode').html(' None');
  426. }
  427. }
  428. if (RepeatMode == 0){
  429. stopbtn();
  430. $('#player').trigger('play');
  431. }else if (RepeatMode == 1){
  432. NextSong();
  433. }else{
  434. stopbtn();
  435. }
  436. });
  437. function volUp(){
  438. var audio = document.getElementById("player");
  439. if (audio.volume > 0.95){
  440. audio.volume = 1;
  441. }else{
  442. audio.volume += 0.05;
  443. }
  444. $('#voldis').html(" " + (Math.round(audio.volume * 100)).toString() + "%");
  445. localStorage.setItem("global_volume", audio.volume);
  446. }
  447. function volDown(){
  448. var audio = document.getElementById("player");
  449. if (audio.volume < 0.05){
  450. audio.volume = 0;
  451. }else{
  452. audio.volume -= 0.05;
  453. }
  454. $('#voldis').html(" " + (Math.round(audio.volume * 100)).toString() + "%");
  455. localStorage.setItem("global_volume", audio.volume);
  456. }
  457. $("#basedirPath").change(function(){
  458. var selectedItem = $("#basedirPath").find(":selected").text();
  459. if (selectedItem == "Internal Storage"){
  460. if (inVDI){
  461. window.location.href = "index.php?mode=fw";
  462. }else{
  463. window.location.href = "index.php";
  464. }
  465. }else{
  466. if (inVDI){
  467. window.location.href = "index.php?mode=fw&extstorage=" + selectedItem.split("/").pop();
  468. }else{
  469. window.location.href = "index.php?extstorage=" + selectedItem.split("/").pop();
  470. }
  471. }
  472. });
  473. //Scroll Controller
  474. $(window).scroll(function (event) {
  475. var scroll = $(window).scrollTop();
  476. if (scroll > 200){
  477. $('#YamiPlayer').css('position', 'fixed');
  478. $('#YamiPlayer').css('top', '0');
  479. $('#YamiPlayer').css('right', '0');
  480. $('#YamiPlayer').css('width', '100%');
  481. $('#YamiPlayer').css('z-index', '1000');
  482. }else if (scroll < 50){
  483. $('#YamiPlayer').css('position', '');
  484. $('#YamiPlayer').css('top', '');
  485. $('#YamiPlayer').css('width', '100%');
  486. $('#YamiPlayer').css('right', '');
  487. $('#YamiPlayer').css('z-index', '');
  488. }
  489. });
  490. function FTF(time)
  491. {
  492. // Hours, minutes and seconds
  493. var hrs = ~~(time / 3600);
  494. var mins = ~~((time % 3600) / 60);
  495. var secs = time % 60;
  496. // Output like "1:01" or "4:03:59" or "123:03:59"
  497. var ret = "";
  498. if (hrs > 0) {
  499. ret += "" + hrs + ":" + (mins < 10 ? "0" : "");
  500. }
  501. ret += "" + mins + ":" + (secs < 10 ? "0" : "");
  502. ret += "" + secs;
  503. return ret;
  504. }
  505. </script>
  506. </body>
  507. </html>