Steven Smith revised this gist . Go to revision
1 file changed, 3 insertions, 5 deletions
mp3list.php
| @@ -78,9 +78,7 @@ $(window).load(function() { | |||
| 78 | 78 | } | |
| 79 | 79 | }); | |
| 80 | 80 | if (window.location.hash != "" || window.location.hash != "#") { | |
| 81 | - | set_src(window.location.hash.substring(1)); | |
| 82 | - | } else { | |
| 83 | - | set_src("<?php echo substr(current($arr), 2); ?>"); | |
| 81 | + | set_src(window.location.hash.substring(1).replace(/%20/g, " ")); | |
| 84 | 82 | } | |
| 85 | 83 | }); | |
| 86 | 84 | </script> | |
| @@ -98,7 +96,7 @@ $(window).load(function() { | |||
| 98 | 96 | foreach($arr as $item) { | |
| 99 | 97 | if (mime_content_type($item) == "audio/mpeg") { | |
| 100 | 98 | $item = substr($item, 2); ?> | |
| 101 | - | <li><a href="#<?php echo htmlentities($item); ?>" onClick='return set_src("<?php echo str_replace(""", "\"", htmlentities($item, ENT_QUOTES)); ?>");'><?php echo $item; ?></a></li> | |
| 99 | + | <li><a href="#<?php echo str_replace(" ", "%20", htmlentities($item)); ?>" onClick='return set_src("<?php echo str_replace(""", "\"", htmlentities($item, ENT_QUOTES)); ?>");'><?php echo $item; ?></a></li> | |
| 102 | 100 | <?php | |
| 103 | 101 | } | |
| 104 | 102 | } | |
| @@ -106,4 +104,4 @@ foreach($arr as $item) { | |||
| 106 | 104 | </ul> | |
| 107 | 105 | </div> | |
| 108 | 106 | </body> | |
| 109 | - | </html> | |
| 107 | + | </html> | |
Steven Smith revised this gist . Go to revision
1 file changed, 1 insertion, 1 deletion
mp3list.php
| @@ -40,7 +40,7 @@ function playRandom() { | |||
| 40 | 40 | ||
| 41 | 41 | function set_src(filename) { | |
| 42 | 42 | window.location.hash = filename.replace(/ /g, "%20"); | |
| 43 | - | document.title = filename; | |
| 43 | + | document.title = filename.replace(/%20/g, " "); | |
| 44 | 44 | try { | |
| 45 | 45 | audio.setAttribute('src', filename); | |
| 46 | 46 | audio.load(); | |
Steven Smith revised this gist . Go to revision
1 file changed, 40 insertions, 25 deletions
mp3list.php
| @@ -1,12 +1,16 @@ | |||
| 1 | 1 | <?php | |
| 2 | + | if (isset($_GET['print'])) { | |
| 3 | + | highlight_file(__FILE__); | |
| 4 | + | die(); | |
| 5 | + | } | |
| 2 | 6 | function load_addon($filename) { | |
| 3 | - | if (file_exists($filename)) { | |
| 4 | - | include $filename; | |
| 5 | - | } | |
| 7 | + | if (file_exists($filename)) { | |
| 8 | + | include $filename; | |
| 9 | + | } | |
| 6 | 10 | } | |
| 7 | 11 | $arr = array(); | |
| 8 | 12 | foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator('.', FilesystemIterator::SKIP_DOTS)) as $item => $file) { | |
| 9 | - | $arr[] = $item; | |
| 13 | + | $arr[] = $item; | |
| 10 | 14 | } | |
| 11 | 15 | sort($arr); | |
| 12 | 16 | ?> | |
| @@ -15,8 +19,8 @@ sort($arr); | |||
| 15 | 19 | <link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" /> | |
| 16 | 20 | <style> | |
| 17 | 21 | div.filelist { | |
| 18 | - | overflow-y: scroll; | |
| 19 | - | height: 90%; | |
| 22 | + | overflow-y: scroll; | |
| 23 | + | height: 90%; | |
| 20 | 24 | } | |
| 21 | 25 | </style> | |
| 22 | 26 | <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | |
| @@ -35,11 +39,17 @@ function playRandom() { | |||
| 35 | 39 | } | |
| 36 | 40 | ||
| 37 | 41 | function set_src(filename) { | |
| 38 | - | audio.setAttribute('src', filename); | |
| 39 | - | audio.load(); | |
| 40 | - | audio.play(); | |
| 41 | - | window.location.hash = filename; | |
| 42 | - | return false; | |
| 42 | + | window.location.hash = filename.replace(/ /g, "%20"); | |
| 43 | + | document.title = filename; | |
| 44 | + | try { | |
| 45 | + | audio.setAttribute('src', filename); | |
| 46 | + | audio.load(); | |
| 47 | + | audio.play(); | |
| 48 | + | $('#np').html(filename.slice(0, -4)); | |
| 49 | + | return false; | |
| 50 | + | } catch(err) { | |
| 51 | + | location.reload(); | |
| 52 | + | } | |
| 43 | 53 | } | |
| 44 | 54 | ||
| 45 | 55 | function setVolume(volume) { | |
| @@ -48,14 +58,14 @@ function setVolume(volume) { | |||
| 48 | 58 | ||
| 49 | 59 | $(window).load(function() { | |
| 50 | 60 | $("#volume").slider({ | |
| 51 | - | min: 0, | |
| 52 | - | max: 100, | |
| 53 | - | value: (audio.volume) * 100, | |
| 54 | - | range: "min", | |
| 55 | - | animate: true, | |
| 56 | - | slide: function(event, ui) { | |
| 57 | - | setVolume((ui.value) / 100); | |
| 58 | - | } | |
| 61 | + | min: 0, | |
| 62 | + | max: 100, | |
| 63 | + | value: (audio.volume) * 100, | |
| 64 | + | range: "min", | |
| 65 | + | animate: true, | |
| 66 | + | slide: function(event, ui) { | |
| 67 | + | setVolume((ui.value) / 100); | |
| 68 | + | } | |
| 59 | 69 | }); | |
| 60 | 70 | audio.setAttribute('src', ''); | |
| 61 | 71 | audio.setAttribute('controls', 'controls'); | |
| @@ -69,6 +79,8 @@ $(window).load(function() { | |||
| 69 | 79 | }); | |
| 70 | 80 | if (window.location.hash != "" || window.location.hash != "#") { | |
| 71 | 81 | set_src(window.location.hash.substring(1)); | |
| 82 | + | } else { | |
| 83 | + | set_src("<?php echo substr(current($arr), 2); ?>"); | |
| 72 | 84 | } | |
| 73 | 85 | }); | |
| 74 | 86 | </script> | |
| @@ -76,19 +88,22 @@ $(window).load(function() { | |||
| 76 | 88 | <body> | |
| 77 | 89 | <form onsubmit="return false;"> | |
| 78 | 90 | <input type="button" onclick="playRandom(); return false;" value="Random"> | |
| 79 | - | <input type="checkbox" name="autoplay" id="autoplay" checked>Autoplay | |
| 91 | + | <label for="autoplay">Autoplay</label><input type="checkbox" name="autoplay" id="autoplay" checked> | |
| 92 | + | <b><span id="np"></span></b> | |
| 80 | 93 | </form> | |
| 81 | 94 | <div id="volume" style="width: 25%"></div> | |
| 82 | 95 | <div class="filelist"> | |
| 83 | 96 | <ul> | |
| 84 | 97 | <?php | |
| 85 | 98 | foreach($arr as $item) { | |
| 86 | - | if (mime_content_type($item) == "audio/mpeg") { | |
| 87 | - | $item = substr($item, 2); ?> | |
| 88 | - | <li><a href="#<?php echo $item; ?>" onClick="return set_src('<?php echo $item; ?>');"><?php echo $item; ?></a></li> | |
| 89 | - | <?php } } | |
| 99 | + | if (mime_content_type($item) == "audio/mpeg") { | |
| 100 | + | $item = substr($item, 2); ?> | |
| 101 | + | <li><a href="#<?php echo htmlentities($item); ?>" onClick='return set_src("<?php echo str_replace(""", "\"", htmlentities($item, ENT_QUOTES)); ?>");'><?php echo $item; ?></a></li> | |
| 102 | + | <?php | |
| 103 | + | } | |
| 104 | + | } | |
| 90 | 105 | ?> | |
| 91 | 106 | </ul> | |
| 92 | 107 | </div> | |
| 93 | 108 | </body> | |
| 94 | - | </html> | |
| 109 | + | </html> | |
Steven Smith revised this gist . Go to revision
1 file changed, 43 insertions, 17 deletions
mp3list.php
| @@ -1,4 +1,9 @@ | |||
| 1 | 1 | <?php | |
| 2 | + | function load_addon($filename) { | |
| 3 | + | if (file_exists($filename)) { | |
| 4 | + | include $filename; | |
| 5 | + | } | |
| 6 | + | } | |
| 2 | 7 | $arr = array(); | |
| 3 | 8 | foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator('.', FilesystemIterator::SKIP_DOTS)) as $item => $file) { | |
| 4 | 9 | $arr[] = $item; | |
| @@ -7,6 +12,7 @@ sort($arr); | |||
| 7 | 12 | ?> | |
| 8 | 13 | <html> | |
| 9 | 14 | <head> | |
| 15 | + | <link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" /> | |
| 10 | 16 | <style> | |
| 11 | 17 | div.filelist { | |
| 12 | 18 | overflow-y: scroll; | |
| @@ -14,24 +20,10 @@ div.filelist { | |||
| 14 | 20 | } | |
| 15 | 21 | </style> | |
| 16 | 22 | <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | |
| 23 | + | <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script> | |
| 17 | 24 | <script> | |
| 18 | - | var audio = document.createElement('audio'); | |
| 19 | 25 | ||
| 20 | - | $(window).load(function() { | |
| 21 | - | audio.setAttribute('src', ''); | |
| 22 | - | audio.setAttribute('controls', 'controls'); | |
| 23 | - | audio.setAttribute('id', 'audio'); | |
| 24 | - | $('body').prepend(audio); | |
| 25 | - | audio.load(); | |
| 26 | - | audio.addEventListener("ended", function () { | |
| 27 | - | if (document.getElementById('autoplay').checked) { | |
| 28 | - | playRandom(); | |
| 29 | - | } | |
| 30 | - | }); | |
| 31 | - | if (window.location.hash != "" || window.location.hash != "#") { | |
| 32 | - | set_src(window.location.hash.substring(1)); | |
| 33 | - | } | |
| 34 | - | }); | |
| 26 | + | var audio = document.createElement('audio'); | |
| 35 | 27 | ||
| 36 | 28 | function playRandom() { | |
| 37 | 29 | try { | |
| @@ -49,10 +41,44 @@ function set_src(filename) { | |||
| 49 | 41 | window.location.hash = filename; | |
| 50 | 42 | return false; | |
| 51 | 43 | } | |
| 44 | + | ||
| 45 | + | function setVolume(volume) { | |
| 46 | + | audio.volume = volume; | |
| 47 | + | } | |
| 48 | + | ||
| 49 | + | $(window).load(function() { | |
| 50 | + | $("#volume").slider({ | |
| 51 | + | min: 0, | |
| 52 | + | max: 100, | |
| 53 | + | value: (audio.volume) * 100, | |
| 54 | + | range: "min", | |
| 55 | + | animate: true, | |
| 56 | + | slide: function(event, ui) { | |
| 57 | + | setVolume((ui.value) / 100); | |
| 58 | + | } | |
| 59 | + | }); | |
| 60 | + | audio.setAttribute('src', ''); | |
| 61 | + | audio.setAttribute('controls', 'controls'); | |
| 62 | + | audio.setAttribute('id', 'audio'); | |
| 63 | + | $('form').prepend(audio); | |
| 64 | + | audio.load(); | |
| 65 | + | audio.addEventListener("ended", function () { | |
| 66 | + | if (document.getElementById('autoplay').checked) { | |
| 67 | + | playRandom(); | |
| 68 | + | } | |
| 69 | + | }); | |
| 70 | + | if (window.location.hash != "" || window.location.hash != "#") { | |
| 71 | + | set_src(window.location.hash.substring(1)); | |
| 72 | + | } | |
| 73 | + | }); | |
| 52 | 74 | </script> | |
| 53 | 75 | </head> | |
| 54 | 76 | <body> | |
| 55 | - | <a href="#" onclick="playRandom(); return false;">Random</a><form><input type="checkbox" name="autoplay" id="autoplay" checked>Autoplay | |
| 77 | + | <form onsubmit="return false;"> | |
| 78 | + | <input type="button" onclick="playRandom(); return false;" value="Random"> | |
| 79 | + | <input type="checkbox" name="autoplay" id="autoplay" checked>Autoplay | |
| 80 | + | </form> | |
| 81 | + | <div id="volume" style="width: 25%"></div> | |
| 56 | 82 | <div class="filelist"> | |
| 57 | 83 | <ul> | |
| 58 | 84 | <?php | |
Steven Smith revised this gist . Go to revision
1 file changed, 29 insertions, 4 deletions
mp3list.php
| @@ -7,37 +7,62 @@ sort($arr); | |||
| 7 | 7 | ?> | |
| 8 | 8 | <html> | |
| 9 | 9 | <head> | |
| 10 | + | <style> | |
| 11 | + | div.filelist { | |
| 12 | + | overflow-y: scroll; | |
| 13 | + | height: 90%; | |
| 14 | + | } | |
| 15 | + | </style> | |
| 10 | 16 | <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | |
| 11 | 17 | <script> | |
| 12 | 18 | var audio = document.createElement('audio'); | |
| 13 | 19 | ||
| 14 | 20 | $(window).load(function() { | |
| 15 | - | audio.setAttribute('src', '<?php echo reset($arr); ?>'); | |
| 21 | + | audio.setAttribute('src', ''); | |
| 16 | 22 | audio.setAttribute('controls', 'controls'); | |
| 17 | 23 | audio.setAttribute('id', 'audio'); | |
| 18 | - | $('body').append(audio); | |
| 19 | - | if (window.location.hash != "" || window.location.hash != "?") { | |
| 24 | + | $('body').prepend(audio); | |
| 25 | + | audio.load(); | |
| 26 | + | audio.addEventListener("ended", function () { | |
| 27 | + | if (document.getElementById('autoplay').checked) { | |
| 28 | + | playRandom(); | |
| 29 | + | } | |
| 30 | + | }); | |
| 31 | + | if (window.location.hash != "" || window.location.hash != "#") { | |
| 20 | 32 | set_src(window.location.hash.substring(1)); | |
| 21 | 33 | } | |
| 22 | 34 | }); | |
| 23 | 35 | ||
| 36 | + | function playRandom() { | |
| 37 | + | try { | |
| 38 | + | var list = $('ul').find('li'); | |
| 39 | + | set_src($(list[Math.floor(Math.random()*list.length)]).find('a')[0].innerHTML); | |
| 40 | + | } catch (err) { | |
| 41 | + | playRandom(); | |
| 42 | + | } | |
| 43 | + | } | |
| 44 | + | ||
| 24 | 45 | function set_src(filename) { | |
| 25 | 46 | audio.setAttribute('src', filename); | |
| 26 | 47 | audio.load(); | |
| 27 | 48 | audio.play(); | |
| 49 | + | window.location.hash = filename; | |
| 28 | 50 | return false; | |
| 29 | 51 | } | |
| 30 | 52 | </script> | |
| 31 | 53 | </head> | |
| 32 | 54 | <body> | |
| 55 | + | <a href="#" onclick="playRandom(); return false;">Random</a><form><input type="checkbox" name="autoplay" id="autoplay" checked>Autoplay | |
| 56 | + | <div class="filelist"> | |
| 33 | 57 | <ul> | |
| 34 | 58 | <?php | |
| 35 | 59 | foreach($arr as $item) { | |
| 36 | 60 | if (mime_content_type($item) == "audio/mpeg") { | |
| 37 | 61 | $item = substr($item, 2); ?> | |
| 38 | - | <li><a href="<?php echo basename(__FILE__) . "#" . $item; ?>" onClick="return set_src('<?php echo $item; ?>');"><?php echo $item; ?></a></li> | |
| 62 | + | <li><a href="#<?php echo $item; ?>" onClick="return set_src('<?php echo $item; ?>');"><?php echo $item; ?></a></li> | |
| 39 | 63 | <?php } } | |
| 40 | 64 | ?> | |
| 41 | 65 | </ul> | |
| 66 | + | </div> | |
| 42 | 67 | </body> | |
| 43 | 68 | </html> | |
Steven Smith revised this gist . Go to revision
1 file changed, 3 insertions, 3 deletions
mp3list.php
| @@ -16,8 +16,8 @@ $(window).load(function() { | |||
| 16 | 16 | audio.setAttribute('controls', 'controls'); | |
| 17 | 17 | audio.setAttribute('id', 'audio'); | |
| 18 | 18 | $('body').append(audio); | |
| 19 | - | if (window.location.search != "" || window.location.search != "?") { | |
| 20 | - | set_src(window.location.search.substring(1)); | |
| 19 | + | if (window.location.hash != "" || window.location.hash != "?") { | |
| 20 | + | set_src(window.location.hash.substring(1)); | |
| 21 | 21 | } | |
| 22 | 22 | }); | |
| 23 | 23 | ||
| @@ -35,7 +35,7 @@ function set_src(filename) { | |||
| 35 | 35 | foreach($arr as $item) { | |
| 36 | 36 | if (mime_content_type($item) == "audio/mpeg") { | |
| 37 | 37 | $item = substr($item, 2); ?> | |
| 38 | - | <li><a href="<?php echo basename(__FILE__) . "?" . $item; ?>" onClick="return set_src('<?php echo $item; ?>');"><?php echo $item; ?></a></li> | |
| 38 | + | <li><a href="<?php echo basename(__FILE__) . "#" . $item; ?>" onClick="return set_src('<?php echo $item; ?>');"><?php echo $item; ?></a></li> | |
| 39 | 39 | <?php } } | |
| 40 | 40 | ?> | |
| 41 | 41 | </ul> | |
Steven Smith revised this gist . Go to revision
1 file changed, 7 insertions, 2 deletions
mp3list.php
| @@ -10,11 +10,15 @@ sort($arr); | |||
| 10 | 10 | <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | |
| 11 | 11 | <script> | |
| 12 | 12 | var audio = document.createElement('audio'); | |
| 13 | + | ||
| 13 | 14 | $(window).load(function() { | |
| 14 | 15 | audio.setAttribute('src', '<?php echo reset($arr); ?>'); | |
| 15 | 16 | audio.setAttribute('controls', 'controls'); | |
| 16 | 17 | audio.setAttribute('id', 'audio'); | |
| 17 | 18 | $('body').append(audio); | |
| 19 | + | if (window.location.search != "" || window.location.search != "?") { | |
| 20 | + | set_src(window.location.search.substring(1)); | |
| 21 | + | } | |
| 18 | 22 | }); | |
| 19 | 23 | ||
| 20 | 24 | function set_src(filename) { | |
| @@ -29,8 +33,9 @@ function set_src(filename) { | |||
| 29 | 33 | <ul> | |
| 30 | 34 | <?php | |
| 31 | 35 | foreach($arr as $item) { | |
| 32 | - | if (mime_content_type($item) == "audio/mpeg") { ?> | |
| 33 | - | <li><a href="<?php echo $item; ?>" onClick="return set_src('<?php echo $item; ?>');"><?php echo substr($item, 2); ?></a></li> | |
| 36 | + | if (mime_content_type($item) == "audio/mpeg") { | |
| 37 | + | $item = substr($item, 2); ?> | |
| 38 | + | <li><a href="<?php echo basename(__FILE__) . "?" . $item; ?>" onClick="return set_src('<?php echo $item; ?>');"><?php echo $item; ?></a></li> | |
| 34 | 39 | <?php } } | |
| 35 | 40 | ?> | |
| 36 | 41 | </ul> | |
Steven Smith revised this gist . Go to revision
1 file changed, 1 insertion, 1 deletion
mp3list.php
| @@ -1,6 +1,6 @@ | |||
| 1 | 1 | <?php | |
| 2 | 2 | $arr = array(); | |
| 3 | - | foreach (iterator_to_array(new RecursiveIteratorIterator(new RecursiveDirectoryIterator('.', FilesystemIterator::SKIP_DOTS))) as $item => $file) { | |
| 3 | + | foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator('.', FilesystemIterator::SKIP_DOTS)) as $item => $file) { | |
| 4 | 4 | $arr[] = $item; | |
| 5 | 5 | } | |
| 6 | 6 | sort($arr); | |
Steven Smith revised this gist . Go to revision
1 file changed, 38 insertions
mp3list.php(file created)
| @@ -0,0 +1,38 @@ | |||
| 1 | + | <?php | |
| 2 | + | $arr = array(); | |
| 3 | + | foreach (iterator_to_array(new RecursiveIteratorIterator(new RecursiveDirectoryIterator('.', FilesystemIterator::SKIP_DOTS))) as $item => $file) { | |
| 4 | + | $arr[] = $item; | |
| 5 | + | } | |
| 6 | + | sort($arr); | |
| 7 | + | ?> | |
| 8 | + | <html> | |
| 9 | + | <head> | |
| 10 | + | <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | |
| 11 | + | <script> | |
| 12 | + | var audio = document.createElement('audio'); | |
| 13 | + | $(window).load(function() { | |
| 14 | + | audio.setAttribute('src', '<?php echo reset($arr); ?>'); | |
| 15 | + | audio.setAttribute('controls', 'controls'); | |
| 16 | + | audio.setAttribute('id', 'audio'); | |
| 17 | + | $('body').append(audio); | |
| 18 | + | }); | |
| 19 | + | ||
| 20 | + | function set_src(filename) { | |
| 21 | + | audio.setAttribute('src', filename); | |
| 22 | + | audio.load(); | |
| 23 | + | audio.play(); | |
| 24 | + | return false; | |
| 25 | + | } | |
| 26 | + | </script> | |
| 27 | + | </head> | |
| 28 | + | <body> | |
| 29 | + | <ul> | |
| 30 | + | <?php | |
| 31 | + | foreach($arr as $item) { | |
| 32 | + | if (mime_content_type($item) == "audio/mpeg") { ?> | |
| 33 | + | <li><a href="<?php echo $item; ?>" onClick="return set_src('<?php echo $item; ?>');"><?php echo substr($item, 2); ?></a></li> | |
| 34 | + | <?php } } | |
| 35 | + | ?> | |
| 36 | + | </ul> | |
| 37 | + | </body> | |
| 38 | + | </html> | |