audio.html 16 KB

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