audio.html 16 KB

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