audio.html 16 KB

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