playback bugz

This commit is contained in:
Jules Laplace
2015-07-11 14:45:48 -04:00
parent 740993b19a
commit 56fcf1b959
4 changed files with 39 additions and 14 deletions

BIN
tv/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@@ -19,10 +19,9 @@ var audio = (function(){
context.decodeAudioData(request.response, function(buf) {
bufs[site.domain] = buf
loader.ready(site.domain + "_sound")
}, function () { console.error('The request failed.') } )
}
request.onerror = function() {
ytmnd.error()
}, function () {
ytmnd.error()
})
}
request.send()
}

View File

@@ -4,7 +4,8 @@ var ytmnd = (function(){
var sites = []
var loaded = {}
var index = 0
var play_immediately = true
var loading = false
var next_domain = ""
var base_href = 'https://ltho.s3.amazonaws.com/ytmnd'
@@ -25,8 +26,26 @@ var ytmnd = (function(){
ytmnd.ready = function(){
shuffle(sites)
ytmnd.bind()
ytmnd.play_index(index)
}
ytmnd.bind = function(){
window.addEventListener("keydown", function(e){
console.log(e.keyCode)
switch (e.keyCode){
case 37: // left
case 38: // up
ytmnd.prev()
break
case 32: // space
case 39: // right
case 40: // down
ytmnd.next()
break
}
})
}
ytmnd.preload = function(site){
site.image_url = base_href + "/" + site.username + "/" + site.domain + "." + site.image_type
@@ -36,6 +55,8 @@ var ytmnd = (function(){
loaded[site.domain] = site
if (next_domain == site.domain) {
ytmnd.play(site)
next_domain = ""
loading = false
}
})
loader.register('init')
@@ -57,12 +78,13 @@ var ytmnd = (function(){
else {
next_domain = site.domain
ytmnd.preload(site)
loading = true
}
}
ytmnd.play = function(site){
document.querySelector("title").innerHTML = site.title
document.body.style.backgroundColor = site.bgcolor
document.body.style.backgroundColor = "#" + site.bgcolor
document.body.style.backgroundImage = "url(" + site.image_url + ")"
document.body.className = site.placement
audio.play(site.domain)
@@ -76,7 +98,7 @@ var ytmnd = (function(){
zoomtext.empty()
}
ytmnd.back = function(){
ytmnd.prev = function(){
ytmnd.stop()
index = (index-1) % sites.length
ytmnd.play_index(index)
@@ -93,6 +115,10 @@ var ytmnd = (function(){
ytmnd.preload_index((index+1) % sites.length)
}, 1000)
}
ytmnd.error = function(){
ytmnd.next()
}
return ytmnd
})()

View File

@@ -13,19 +13,19 @@ var zoomtext = (function(){
return zoomtext.empty()
}
var text = ytmnd_info['site']['zoom_text']
var text = site['zoom_text']
var offset = 100, rows = ""
if ("line_3" in zoom_text && zoom_text["line_3"].length > 0) {
rows += zoomtext.add_row( zoom_text['line_3'], offset, 500 )
if ("line_3" in zoom_text && text["line_3"].length > 0) {
rows += zoomtext.add_row( text['line_3'], offset, 500 )
offset += 50
}
if ("line_2" in zoom_text && zoom_text["line_2"].length > 0) {
rows += zoomtext.add_row( zoom_text['line_2'], offset, 250 )
if ("line_2" in zoom_text && text["line_2"].length > 0) {
rows += zoomtext.add_row( text['line_2'], offset, 250 )
offset += 50
}
if ("line_1" in zoom_text && zoom_text["line_1"].length > 0) {
rows += zoomtext.add_row( zoom_text['line_1'], offset, 500 )
if ("line_1" in zoom_text && text["line_1"].length > 0) {
rows += zoomtext.add_row( text['line_1'], offset, 500 )
}
el.innerHTML = rows.join("")