This commit is contained in:
Seth Call 2015-02-03 09:25:45 -06:00
parent c4c05c67d6
commit 503e46ed74
5 changed files with 66 additions and 16 deletions

View File

@ -1,8 +1,8 @@
CREATE TABLE backing_tracks ( CREATE UNLOGGED TABLE backing_tracks (
id VARCHAR(64) NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), id VARCHAR(64) NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(),
filename VARCHAR(1024) NOT NULL, filename VARCHAR(1024) NOT NULL,
connection_id VARCHAR(64) NOT NULL, connection_id VARCHAR(64) NOT NULL REFERENCES connections(id) ON DELETE CASCADE,
client_track_id VARCHAR(64) NOT NULL, client_track_id VARCHAR(64) NOT NULL,
client_resource_id VARCHAR(100), client_resource_id VARCHAR(100),
@ -13,7 +13,7 @@ CREATE TABLE backing_tracks (
CREATE TABLE recorded_backing_tracks ( CREATE TABLE recorded_backing_tracks (
id BIGINT PRIMARY KEY, id BIGINT PRIMARY KEY,
user_id VARCHAR(64) REFERENCES users(id) ON DELETE CASCADE, user_id VARCHAR(64) REFERENCES users(id) ON DELETE CASCADE,
backing_track_id VARCHAR(64) REFERENCES backing_tracks(id) ON DELETE CASCADE, backing_track_id VARCHAR(64),
recording_id VARCHAR(64) NOT NULL, recording_id VARCHAR(64) NOT NULL,
client_track_id VARCHAR(64) NOT NULL, client_track_id VARCHAR(64) NOT NULL,

View File

@ -28,7 +28,8 @@
emptyList(); emptyList();
resetPagination(); resetPagination();
showing = true; showing = true;
getBackingTracks() getBackingTracks();
$dialog.data('result', null);
// .done(function(data, textStatus, jqXHR) { // .done(function(data, textStatus, jqXHR) {
// // initialize pagination // // initialize pagination
// var $paginator = context.JK.Paginator.create(parseInt(jqXHR.getResponseHeader('total-entries')), perPage, 0, onPageSelected) // var $paginator = context.JK.Paginator.create(parseInt(jqXHR.getResponseHeader('total-entries')), perPage, 0, onPageSelected)
@ -93,6 +94,8 @@
// TODO: Possibly actually check the result. Investigate // TODO: Possibly actually check the result. Investigate
// what real client returns: // what real client returns:
// // if(result) { // // if(result) {
// let callers see which backing track was chosen
$dialog.data('result', backingTrack);
app.layout.closeDialog('open-backing-track-dialog'); app.layout.closeDialog('open-backing-track-dialog');
// } // }
// else { // else {

View File

@ -2152,8 +2152,11 @@
return false; return false;
} }
app.layout.showDialog('open-backing-track-dialog'); app.layout.showDialog('open-backing-track-dialog').one(EVENTS.DIALOG_CLOSED, function(e, data) {
if(!data.cancel && data.result){
sessionModel.setBackingTrack(data.result);
}
})
return false; return false;
} }
@ -2184,7 +2187,7 @@
return false; return false;
} else { } else {
context.jamClient.openBackingTrackFile(sessionModel.backing_track) context.jamClient.openBackingTrackFile(sessionModel.backing_track)
context.JK.CurrentSessionModel.refreshCurrentSession(true); //context.JK.CurrentSessionModel.refreshCurrentSession(true);
} }
return false; return false;
} }
@ -2294,14 +2297,15 @@
closeMetronomeTrack(); closeMetronomeTrack();
} }
else { else {
logger.error("don't know how to close open media (backing track?)"); logger.error("don't know how to close open media");
} }
return false;
} }
function closeBackingTrack() { function closeBackingTrack() {
rest.closeBackingTrack({id: sessionModel.id()}) rest.closeBackingTrack({id: sessionModel.id()})
.done(function() { .done(function() {
sessionModel.refreshCurrentSession(true); //sessionModel.refreshCurrentSession(true);
}) })
.fail(function(jqXHR) { .fail(function(jqXHR) {
app.notify({ app.notify({
@ -2311,7 +2315,8 @@
}); });
}); });
context.jamClient.SessionCloseBackingTrackFile(); // '' closes all open backing tracks
context.jamClient.SessionCloseBackingTrackFile('');
return false; return false;
} }

View File

@ -34,6 +34,8 @@
var sessionPageEnterTimeout = null; var sessionPageEnterTimeout = null;
var startTime = null; var startTime = null;
var joinDeferred = null; var joinDeferred = null;
var previousBackingTracks = [];
var openBackingTrack = null;
var mixerMode = MIX_MODES.PERSONAL; var mixerMode = MIX_MODES.PERSONAL;
@ -324,6 +326,8 @@
} }
currentSessionId = null; currentSessionId = null;
currentParticipants = {} currentParticipants = {}
previousBackingTracks = []
openBackingTrack = null
} }
// you should only update currentSession with this function // you should only update currentSession with this function
@ -557,23 +561,31 @@
return mixerMode; return mixerMode;
} }
function syncTracks() { function syncTracks(backingTracks) {
// double check that we are in session, since a bunch could have happened since then // double check that we are in session, since a bunch could have happened since then
if(!inSession()) { if(!inSession()) {
logger.debug("dropping queued up sync tracks because no longer in session"); logger.debug("dropping queued up sync tracks because no longer in session");
return; return null;
} }
// this is a local change to our tracks. we need to tell the server about our updated track information // this is a local change to our tracks. we need to tell the server about our updated track information
var inputTracks = context.JK.TrackHelpers.getUserTracks(context.jamClient); var inputTracks = context.JK.TrackHelpers.getUserTracks(context.jamClient);
// backingTracks can be passed in as an optimization, so that we don't hit the backend excessively
if(backingTracks === undefined) {
backingTracks = context.JK.TrackHelpers.getBackingTracks(context.jamClient);
}
console.log('backingTracks', backingTracks);
// create a trackSync request based on backend data // create a trackSync request based on backend data
var syncTrackRequest = {}; var syncTrackRequest = {};
syncTrackRequest.client_id = app.clientId; syncTrackRequest.client_id = app.clientId;
syncTrackRequest.tracks = inputTracks; syncTrackRequest.tracks = inputTracks;
syncTrackRequest.backing_tracks = backingTracks;
syncTrackRequest.id = id(); syncTrackRequest.id = id();
rest.putTrackSyncChange(syncTrackRequest) return rest.putTrackSyncChange(syncTrackRequest)
.done(function() { .done(function() {
}) })
.fail(function(jqXHR) { .fail(function(jqXHR) {
@ -733,7 +745,6 @@
// wait until we are fully in session before trying to sync tracks to server // wait until we are fully in session before trying to sync tracks to server
if(joinDeferred) { if(joinDeferred) {
joinDeferred.done(function() { joinDeferred.done(function() {
syncTracks(); syncTracks();
}) })
} }
@ -742,8 +753,17 @@
} }
else if(inSession() && (text == 'RebuildMediaControl' || text == 'RebuildRemoteUserControl')) { else if(inSession() && (text == 'RebuildMediaControl' || text == 'RebuildRemoteUserControl')) {
// var backingTracks = context.JK.TrackHelpers.getBackingTracks(context.jamClient);
refreshCurrentSession(true);
// the way we know if backing tracks changes, or recordings are opened, is via this event.
// but we want to report to the user when backing tracks change; so we need to detect change on our own
if(previousBackingTracks != backingTracks) {
logger.debug("backing tracks changed")
syncTracks(backingTracks);
}
else {
refreshCurrentSession(true);
}
} }
else if(inSession() && (text == 'Global Peer Input Mixer Mode')) { else if(inSession() && (text == 'Global Peer Input Mixer Mode')) {
setMixerMode(MIX_MODES.MASTER); setMixerMode(MIX_MODES.MASTER);
@ -796,6 +816,12 @@
this.getParticipant = function(clientId) { this.getParticipant = function(clientId) {
return participantsEverSeen[clientId] return participantsEverSeen[clientId]
}; };
this.setBackingTrack = function(backingTrack) {
openBackingTrack = backingTrack;
};
this.getBackingTrack = function() {
return openBackingTrack;
};
// call to report if the current user was able to establish audio with the specified clientID // call to report if the current user was able to establish audio with the specified clientID
this.setAudioEstablished = function(clientId, audioEstablished) { this.setAudioEstablished = function(clientId, audioEstablished) {

View File

@ -30,6 +30,22 @@
return tracks; return tracks;
}, },
getBackingTracks: function(jamClient) {
var mediaTracks = context.JK.TrackHelpers.getTracks(jamClient, 4);
var backingTracks = []
context._.each(mediaTracks, function(mediaTrack) {
var track = {};
track.client_track_id = mediaTrack.id;
track.client_resource_id = mediaTrack.rid;
track.filename = mediaTrack.id;
backingTracks.push(track);
})
return backingTracks;
},
/** /**
* This function resolves which tracks to configure for a user * This function resolves which tracks to configure for a user
* when creating or joining a session. By default, tracks are pulled * when creating or joining a session. By default, tracks are pulled