Thursday, November 14, 2019

so, i'm past my bed time now and i need a nap.

but, that sets up the template, which should speed me up.
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.
the buttons are fine for the forwards and backwards, but this is much nicer for the tables.

<table>
<tr><td onclick="Player.src = nextsrc[0]; Player.play();">1. track 1</td></tr>
<tr><td onclick="Player.src = nextsrc[1]; Player.play();">2. track 2</td></tr>
<tr><td onclick="Player.src = nextsrc[2]; Player.play();">3. track 3</td></tr>
<tr><td>4</td></tr>
.
.
.
.
</table>
error checking?

let the fuckers fuck up. i don't fucking care.
i stole the basic logic of this out of a forum, then added the extra buttons in. if you want a playlist, it's about as simple as it gets.

no js. no css. you can do that yourself. just paste this into an html document...

//back button. it just keeps going, so don't be stupid.
<button type="button" onclick="Player.src = nextsrc[--elm]; Player.play();">&lt;</button>

//html5 player
<audio autoplay controls id="Player" src="track 1"></audio>

//forward button. likewise, there's no end, here.
<button type="button" onclick="Player.src = nextsrc[++elm]; Player.play();">&gt;</button>

//tracklisting
<table>
<tr><td><button type="button" onclick="Player.src = nextsrc[0]; Player.play();">1</button></td></tr>
<tr><td><button type="button" onclick="Player.src = nextsrc[1]; Player.play();">2</button></td></tr>
<tr><td>3</td></tr>
<tr><td>4</td></tr>
.
.
.
</table>
</p>

//"script"
<script>
var nextsrc = [track list];
var elm = 0; var Player = document.getElementById('Player');
Player.onended = function(){
    if(++elm < nextsrc.length){   
         Player.src = nextsrc[elm]; Player.play();
    }
}
</script>

that's it.
so, there's no easy way to build an html5 playlist...

the only way i can do this that i actually like is to build my own java script directly into the document, utilizing the built-in functionality, but i'm not sure how well i'm going to like this. i don't want to cite external routines, i don't want to put in an existing player, etc. what if they move the document? i mean, look at what's coming up with my own site.

i don't want to stream the audio from the cloud - they just bought it, they have it in high quality in front of them. that's the point.

and, i don't want to enforce a plugin. i'll give you an m3u file instead as that's what i was trying to actually do. i use foobar. maybe you like something else.

and, then i kind of thought it through and it seemed silly, because buying the audio means you'll do what you will with it, and that's the point.

but, i still want a little front end.

i should be able to do this by just creating a couple of buttons right in the document. you'll need javascript on, unfortunately. it won't be pretty. but it'll work.
they're closed until the morning. and i'm going to get back to work and finish the html frontend before i stop to eat.

the fan is not here yet, but i've got some stats on what's running, anyways:

bathroom fan: 0.07 kwh/hr
laptop + modem + lights: 0.08 kwh/hr  (before turning devices off in dev mgr)
desktop fan: 0.09 kwh/hr

the only other thing running is the fridge, which i think is about 0.01.

so,

bathroom fan is 0.06*24*30 =  43.2 kwh
laptop + modem + lights is 0.07*24*30 =  50.4 kwh
desktop fan is .08*24*30 = 57.6 kwh

together, that's 151.2 kwh. my bills have been in the 160-190 kwh range, which would also include cooking and laundry. of course, the bathroom fan has been off here and there, while the computers have generally been off when i'm out, but the desktop fan has been on non-stop.

i was able to get monday close to 0.30 at off peak rates (although it was close to 0.50 at on peak rates). doing the math gets me close enough, and that's with the desktop fan on.

i want to do some more careful calculations. how much is just the modem + fan? how much is just the lights (in this room) + fan? laptop + fan? i'm confident about the fan, itself, so i should get some good estimates and be able to figure out what's worth shutting off and what isn't.

i might guess that it's something like the following to run each 24/7:

lights: 0.01 ----> 7.2----->$0.69
modem: 0.02 -----> 14.4---->$1.37
laptop: 0.04 -----> 28.8----> $2.73

....meaning i should probably be less neurotic about the time of day they're on and just turn them off when i'm not using them.

if i can take 50-70 out for this month by just keeping the fan off and the general usage down, i should offset the increase, at least.

the key point is that i can't be haphazard anymore.
i tried to go to google sites, and it's just....what?

i'm not a tactile learner. these guis-for-arts-students are just confusing as fuck. i don't want to draw it. let me code it, dammit...

but, i mean, theoretically? sure. i don't need to use the appengine, exactly - i'm not scripting. it's just text. but, i do need to be able to ftp it to the server.

ok. i'm calling td.
well, i applied through simplii.

i'd guess the chances are pretty low.

i did have a credit card with td at one point, but i cut up the card. i didn't cancel it. i just paid it down and threw it away. if i run a credit check on myself, the card does come up as active.

so, i'm going to call td and see what they say...