Thursday, November 14, 2019

i'm going to post a last update to this - and it's now done - because i'm solving some problems that some other people are having problems with.

java is actually one of the many things that i'm technically an expert in. so, this is very simple code - because it should be. there's no reason for this to be complicated, and that complexity is exactly what i want to avoid.

//i'm centering this. i guess you don't have to. but, it's more zen.
<p align="center">

//this produces a text box that will output the file name. i'm sort of cheating, because i typed in the playlist. but, it works.
<input disabled type = "text"  style="width:300px;background-color:#000000;border-width:0px;" id = "txtOutput"/>
<br>

//this is the new back button. no error handling, but it matters even less, now.
<button type="button"  style="font-size:50px;" onclick="Player.src = nextsrc[--elm]; Player.play(); txtOutput.value = titles[elm]">&lt;</button>

//this is the html5 control
<audio autoplay controls  style="width:500px;height:50px"  id="Player" src="first track">Your browser does not support the video tag.</audio>

//this is the forward button. still no error handling.
<button type="button"  style="font-size:50px;" onclick="Player.src = nextsrc[++elm]; Player.play(); txtOutput.value = titles[elm]">&gt;</button>

//this is the new, more interactive html table
//notice that the index increases for each entry
//i am also resetting the index here to keep things in sync
//the width is set to 200 because i'm actually using two columns (i've deleted the second for brevity and clarity)
<table>
<tr><td width=200 onclick="Player.src = nextsrc[0]; Player.play(); elm=0; txtOutput.value = this.innerHTML">1. track 1 </td>
<tr><td onclick="Player.src = nextsrc[1]; Player.play(); elm=1;  txtOutput.value = this.innerHTML">2. track 2</td>
.
.
.
</table>

//here is the script.
<script>
var nextsrc = [list of file paths];
var titles =[list of file titles]
var elm = 0; var Player = document.getElementById('Player');
Player.onended = function(){
    if(++elm < nextsrc.length){  
         Player.src = nextsrc[elm]; Player.play();
         txtOutput.value = titles[elm];
    }
}
</script>
</p>

============

again, this is a nice little player. you just need to input the titles manually - or you could write a short program to parse it from an m3u file.

i'm kind of proud of myself.


1) back/forth buttons work fine. if you keep pushing the buttons out of bounds, you will have to rewind them as far as you pushed them. you could be really retarded and create an error, i'm sure. i'm not worried about it.
2) even if you go way out of bounds, you can fall back in bounds by clicking a track in the list. it'll reset itself and works fine.
3) you can jump from any track to any other track. it's just an index.
4) the record actually plays through, and the "playing" track updates properly along the way.

so, basically, it works perfectly.