Skip to content

Commit

Permalink
Speaker v0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
tanelt committed Mar 25, 2012
1 parent ebba023 commit e4e7d35
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
11 changes: 10 additions & 1 deletion lib/public/css/style.css
Expand Up @@ -269,14 +269,23 @@ body {
background-size: contain;
}

#loading {
position: relative;
z-index: 1300;
top: 10.7em;
left: -1.7em;
font-weight: bold;
}

#speaker-on {
position: absolute;
top: 8.4em;
left: 9.4em;
width: 3.4em;
height: 3.4em;
background: #25E610;
background: #8dc63f;
-webkit-border-radius: 3.4em;
-webkit-box-shadow: 0 0 5px 5px #888;
display: none;
}

Expand Down
25 changes: 10 additions & 15 deletions lib/public/js/app_client.js
Expand Up @@ -30,7 +30,6 @@ ms.ready = function(trackId){
$(function() {
_.extend(ms, {
player: null,
timeSyncReady: false,
loadedTrack: null,
payloadQueue: [],

Expand Down Expand Up @@ -135,7 +134,7 @@ $(function() {

playTrack: function(spriteid, offset) {
var track = ms.loadedTrack;
if (!ms.timeSyncReady || !track || track && !track.spritemap[spriteid]) {
if (!track || track && !track.spritemap[spriteid]) {
return;
}
var pos = ms.player.settings["spritemap"][spriteid].start;
Expand All @@ -147,7 +146,7 @@ $(function() {

// Animate speaker
$("#speaker-animation").show();

$("#loading").hide();
// Update treack time left
ms.trackInterval = setInterval(function() {
$("#time").html(ms.formatDuration(ms.player.context));
Expand All @@ -163,6 +162,9 @@ $(function() {
$("#speaker-animation").hide();
clearInterval(ms.trackInterval);
ms.player.pause();

// Reload
document.location.reload();
},

updateSpeakerCount: function(total) {
Expand Down Expand Up @@ -216,17 +218,13 @@ $(function() {
ms.on('payload', ms.onQueuePayload);

// Play and stop request
// ms.on('play', ms.playTrack);
// ms.on('pause', ms.pauseTrack);
// ms.on('stop', ms.stopTrack);
ms.on('play', ms.playTrack);
ms.on('pause', ms.pauseTrack);
ms.on('stop', ms.stopTrack);

ms.on("speakerCount", ms.updateSpeakerCount);
ms.on("loadedCount", ms.updateLoadedCount);

// Sync time
ms.timesync.on('ready', function() {
ms.timeSyncReady = true;
});
setInterval(_.bind(ms.step,ms), 1);

ms.errors = 0;
Expand All @@ -248,18 +246,15 @@ $(function() {
}
}

if(ms.isloading && !ms.loaded){
if(ms.player && ms.isloading && !ms.loaded){
console.log((ms.player.context.readyState == 4)+' '+(ms.player.context.buffered.length)+' '+ (ms.player.context.buffered.end(0))+' '+ (ms.track.duration));
$("#loading").show().html(Math.round(100*(ms.player.context.buffered.end(0) / (ms.track.duration+1))));
if(ms.player.context.readyState == 4 && ms.player.context.buffered.length && ms.player.context.buffered.end(0) >= ms.track.duration){
console.log('audio was ready');
ms.audioReady();
}
}
else{
$("#loading").hide();
}
},1000);
}, 1000);

window.addEventListener('pageshow', function(){
if(window.pagehide) {
Expand Down

0 comments on commit e4e7d35

Please sign in to comment.