Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/tanelt/megaspeaker
Browse files Browse the repository at this point in the history
Conflicts:
	lib/public/js/app_client.js
  • Loading branch information
msokk committed Mar 25, 2012
2 parents 2ff0f6c + 9738a13 commit 1781629
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions lib/public/js/app_client.js
Expand Up @@ -114,7 +114,6 @@ $(function() {
}

ms.player.pause();
//ms.player.pause();
ms.player.resource = jukebox.Manager.getPlayableResource(track.resources);
for (var s in track) {
ms.player.settings[s] = track[s];
Expand All @@ -134,7 +133,7 @@ $(function() {

playTrack: function(spriteid, offset) {
var track = ms.loadedTrack;
if (!track || track && !track.spritemap[spriteid]) {
if (!ms.player || !track || track && !track.spritemap[spriteid]) {
return;
}
var pos = ms.player.settings["spritemap"][spriteid].start;
Expand All @@ -149,10 +148,12 @@ $(function() {
$("#loading").hide();
// Update treack time left
ms.trackInterval = setInterval(function() {
$("#time").html(ms.formatDuration(ms.player.context));
if (ms.player.context.duration === ms.player.context.currentTime) {
clearInterval(ms.trackInterval);
ms.trigger("stop");
if (ms.player) {
$("#time").html(ms.formatDuration(ms.player.context));
if (ms.player.context.duration === ms.player.context.currentTime) {
clearInterval(ms.trackInterval);
ms.stopTrack();
}
}
}, 1000);
//console.log('playTrack '+spriteid+' '+(ms.timesync.getTime())+'');
Expand All @@ -161,9 +162,19 @@ $(function() {
stopTrack: function(){
$("#speaker-animation").hide();
clearInterval(ms.trackInterval);
<<<<<<< HEAD
ms.player.pause();

// Reload
=======
ms.player && ms.player.pause();
ms.payloadQueue = [];

$("#speaker-on").show();
$("#speaker-animation").hide();
// Fallback to reload
>>>>>>> 9738a139033cd7ae4114aac0e23484855876a42d
document.location.reload();
},
Expand Down Expand Up @@ -217,11 +228,6 @@ $(function() {
// Add payload to queue
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("speakerCount", ms.updateSpeakerCount);
ms.on("loadedCount", ms.updateLoadedCount);

Expand All @@ -230,7 +236,7 @@ $(function() {
ms.errors = 0;

setInterval(function(){
if(ms.playing){
if(ms.playing && ms.player){
diff = (ms.player.context.currentTime-ms.playOffset)*1000 - (ms.timesync.getTime()-ms.playTime) + ms.deviceLatency;
//console.log('latency '+(diff-ms.deviceLatency));
if(diff > 0 || diff < -400){
Expand Down

0 comments on commit 1781629

Please sign in to comment.