2012-10-06 16:36:05 +00:00
|
|
|
(function(context,$) {
|
|
|
|
|
|
2012-12-07 00:28:48 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
2012-10-06 16:36:05 +00:00
|
|
|
context.JK = context.JK || {};
|
|
|
|
|
context.JK.SessionScreen = function(app) {
|
2012-10-14 15:48:56 +00:00
|
|
|
var logger = context.JK.logger;
|
2012-10-29 15:10:02 +00:00
|
|
|
var sessionId;
|
2012-11-03 20:25:23 +00:00
|
|
|
var session = null;
|
|
|
|
|
var users = {}; // Light cache of user info for session users.
|
2012-10-22 02:55:05 +00:00
|
|
|
var tracks = {};
|
2013-01-30 16:50:43 +00:00
|
|
|
var mixers = [];
|
2013-02-03 19:48:39 +00:00
|
|
|
var $draggingFaderHandle = null;
|
2013-02-03 17:50:26 +00:00
|
|
|
var $draggingFader = null;
|
2013-02-03 19:48:39 +00:00
|
|
|
var currentMixerId = null;
|
2013-02-03 22:47:17 +00:00
|
|
|
var currentMixerRangeMin = null;
|
|
|
|
|
var currentMixerRangeMax = null;
|
2012-10-06 16:36:05 +00:00
|
|
|
|
2013-01-31 05:23:30 +00:00
|
|
|
// Replicate the Channel Group enum from C++
|
|
|
|
|
var ChannelGroupIds = {
|
|
|
|
|
0: "MasterGroup",
|
|
|
|
|
1: "MonitorGroup",
|
|
|
|
|
2: "AudioInputMusicGroup",
|
|
|
|
|
3: "AudioInputChatGroup",
|
|
|
|
|
4: "MediaTrackGroup",
|
|
|
|
|
5: "StreamOutMusicGroup",
|
|
|
|
|
6: "StreamOutChatGroup",
|
|
|
|
|
7: "UserMusicInputGroup",
|
|
|
|
|
8: "UserChatInputGroup",
|
|
|
|
|
9: "PeerAudioInputMusicGroup"
|
|
|
|
|
};
|
|
|
|
|
|
2013-02-03 22:47:17 +00:00
|
|
|
// Group 0 is the master mix. Mixer ID should go with the top horizontal volume slider, and possibly new VU meter.
|
|
|
|
|
// Group 1 is the monitor mix. Currently no UI component.
|
|
|
|
|
// Group 2 is my local music input. Any tracks here go into "My Tracks"
|
|
|
|
|
// Group 3 is my local voice chat.
|
|
|
|
|
// Group 4 is media files -- for sure for me locally, possibly from others?
|
|
|
|
|
|
2012-10-29 15:10:02 +00:00
|
|
|
function beforeShow(data) {
|
|
|
|
|
sessionId = data.id;
|
|
|
|
|
}
|
2012-10-29 00:37:59 +00:00
|
|
|
|
2012-10-06 16:36:05 +00:00
|
|
|
function afterShow(data) {
|
2012-12-07 00:28:48 +00:00
|
|
|
context.JK.joinMusicSession(sessionId, app);
|
2013-01-30 16:50:43 +00:00
|
|
|
// Subscribe for callbacks on audio events
|
|
|
|
|
context.jamClient.SessionRegisterCallback("JK.HandleBridgeCallback");
|
2012-10-06 16:36:05 +00:00
|
|
|
$.ajax({
|
|
|
|
|
type: "GET",
|
|
|
|
|
url: "/api/sessions/" + sessionId
|
2012-11-03 20:25:23 +00:00
|
|
|
}).done(updateSession);
|
2012-10-29 00:37:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function beforeHide(data) {
|
2012-11-03 20:25:23 +00:00
|
|
|
// Move joinSession function to this file for ease of finding it?
|
2012-10-29 00:37:59 +00:00
|
|
|
context.JK.leaveMusicSession(sessionId);
|
2013-01-31 05:23:30 +00:00
|
|
|
// 'unregister' for callbacks
|
|
|
|
|
context.jamClient.SessionRegisterCallback("");
|
2012-10-06 16:36:05 +00:00
|
|
|
}
|
|
|
|
|
|
2012-11-03 20:25:23 +00:00
|
|
|
function updateSession(sessionData) {
|
|
|
|
|
session = sessionData;
|
|
|
|
|
updateParticipants(function() { renderSession(); });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Make sure that for each participant in the session, we have user info.
|
|
|
|
|
*/
|
|
|
|
|
function updateParticipants(onComplete) {
|
|
|
|
|
var callCount = 0;
|
|
|
|
|
$.each(session.participants, function(index, value) {
|
2013-01-31 04:00:07 +00:00
|
|
|
if (!(this.user.id in users)) {
|
2012-11-03 20:25:23 +00:00
|
|
|
callCount += 1;
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "GET",
|
2013-01-31 04:00:07 +00:00
|
|
|
url: "/api/users/" + this.user.id
|
2012-11-03 20:25:23 +00:00
|
|
|
}).done(function(user) {
|
|
|
|
|
callCount -= 1;
|
|
|
|
|
users[user.id] = user;
|
2013-01-31 04:00:07 +00:00
|
|
|
// We'll be using our own photo url instead of gravatar.
|
|
|
|
|
//var hash = context.JK.calcMD5(user.email);
|
|
|
|
|
//users[user.id].photo_url = 'http://www.gravatar.com/avatar/' + hash;
|
2012-11-03 20:25:23 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if (!(onComplete)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// TODO: generalize this pattern. Likely needed elsewhere.
|
|
|
|
|
function checker() {
|
|
|
|
|
if (callCount === 0) {
|
|
|
|
|
onComplete();
|
|
|
|
|
} else {
|
2012-12-07 00:28:48 +00:00
|
|
|
context.setTimeout(checker, 10);
|
2012-11-03 20:25:23 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
checker();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderSession() {
|
2013-01-30 16:50:43 +00:00
|
|
|
_updateMixers();
|
2012-11-03 20:25:23 +00:00
|
|
|
_renderTracks();
|
2013-01-30 16:50:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get the latest list of underlying audio mixer channels
|
|
|
|
|
function _updateMixers() {
|
2013-01-31 16:32:32 +00:00
|
|
|
var mixerIds = context.jamClient.SessionGetIDs();
|
|
|
|
|
mixers = context.jamClient.SessionGetControlState(mixerIds);
|
2012-10-21 23:03:46 +00:00
|
|
|
}
|
|
|
|
|
|
2013-01-30 16:50:43 +00:00
|
|
|
// Given a clientId, return a dictionary of mixer ids which
|
|
|
|
|
// correspond to that client's tracks
|
|
|
|
|
// TODO - this is hard-coded. Need fix from Nat
|
2013-01-31 16:32:32 +00:00
|
|
|
function _inputMixerForClient(clientId) {
|
|
|
|
|
// Iterate over the mixers, but simply return the first
|
|
|
|
|
// mixer in the AudioInputMusicGroup
|
|
|
|
|
var mixer = null;
|
|
|
|
|
for (var i=0; i<mixers.length; i++) {
|
|
|
|
|
mixer = mixers[i];
|
|
|
|
|
if (mixer.group_id === 2) {
|
|
|
|
|
return mixer.id;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null; // no audio input music mixers.
|
2013-01-30 16:50:43 +00:00
|
|
|
}
|
|
|
|
|
|
2012-11-03 20:25:23 +00:00
|
|
|
function _renderTracks() {
|
2013-01-30 16:50:43 +00:00
|
|
|
var participantCount = 0;
|
2013-01-31 16:32:32 +00:00
|
|
|
var inputMixer = null;
|
2012-11-03 20:25:23 +00:00
|
|
|
$.each(session.participants, function(index, value) {
|
|
|
|
|
if (!(this.client_id in tracks)) {
|
2013-01-31 04:00:07 +00:00
|
|
|
var user = users[this.user.id];
|
2013-01-30 16:50:43 +00:00
|
|
|
// TODO - handle multiple tracks for one user
|
2013-01-31 16:32:32 +00:00
|
|
|
inputMixer = _inputMixerForClient(this.client_id);
|
2012-11-03 20:25:23 +00:00
|
|
|
var trackData = {
|
|
|
|
|
clientId: this.client_id,
|
2013-01-30 16:50:43 +00:00
|
|
|
name: user.first_name + ' ' + user.last_name,
|
2012-11-03 20:25:23 +00:00
|
|
|
part: "Keyboard", // TODO - need this
|
|
|
|
|
avatar: user.photo_url,
|
|
|
|
|
latency: "good",
|
|
|
|
|
vu: 0.0,
|
|
|
|
|
gain: 0.5,
|
2013-01-30 16:50:43 +00:00
|
|
|
mute: false,
|
2013-01-31 16:32:32 +00:00
|
|
|
mixerId: inputMixer
|
2012-11-03 20:25:23 +00:00
|
|
|
};
|
|
|
|
|
_addTrack(trackData);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
// Trim out any participants who are no longer in the session.
|
|
|
|
|
for (var clientId in tracks) {
|
|
|
|
|
var hasLeftSession = true;
|
|
|
|
|
for (var i=0; i<session.participants.length; i++) {
|
|
|
|
|
var participantId = session.participants[i].client_id;
|
|
|
|
|
if (participantId === clientId) {
|
|
|
|
|
hasLeftSession = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (hasLeftSession) {
|
|
|
|
|
$('[client-id="' + clientId + '"]').remove();
|
|
|
|
|
delete tracks[clientId];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-30 16:50:43 +00:00
|
|
|
// Given a mixerID and a value between 0.0-1.0,
|
|
|
|
|
// light up the proper VU lights.
|
|
|
|
|
function _updateVU(mixerId, value) {
|
2013-01-31 16:32:32 +00:00
|
|
|
// Minor tweak to support VU values -- the mixerId here will
|
|
|
|
|
// have a suffix added _vul or _vur to indicate the channel.
|
2013-01-30 16:50:43 +00:00
|
|
|
// There are 13 VU lights. Figure out how many to
|
|
|
|
|
// light based on the incoming value.
|
|
|
|
|
var i = 0;
|
|
|
|
|
var state = 'on';
|
|
|
|
|
var lights = Math.round(13 * value);
|
|
|
|
|
var selector = null;
|
|
|
|
|
var $light = null;
|
|
|
|
|
var colorClass = 'vu-green-';
|
|
|
|
|
// Remove all light classes from all lights
|
2013-01-31 16:32:32 +00:00
|
|
|
var allLightsSelector = '#tracks table[mixer-id="' + mixerId + '"] td.vulight';
|
2013-01-30 16:50:43 +00:00
|
|
|
$(allLightsSelector).removeClass('vu-green-off vu-green-on vu-red-off vu-red-on');
|
|
|
|
|
|
|
|
|
|
// Set the lights
|
|
|
|
|
for (i=0; i<13; i++) {
|
|
|
|
|
colorClass = 'vu-green-';
|
|
|
|
|
state = 'on';
|
|
|
|
|
if (i > 8) {
|
|
|
|
|
colorClass = 'vu-red-';
|
|
|
|
|
}
|
|
|
|
|
if (i >= lights) {
|
|
|
|
|
state = 'off';
|
|
|
|
|
}
|
2013-01-31 16:32:32 +00:00
|
|
|
selector = '#tracks table[mixer-id="' + mixerId + '"] td.vu' + i;
|
2013-01-30 16:50:43 +00:00
|
|
|
$light = $(selector);
|
|
|
|
|
$light.addClass(colorClass + state);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-21 23:03:46 +00:00
|
|
|
function _addTrack(trackData) {
|
2013-01-29 16:30:45 +00:00
|
|
|
trackData["left-vu"] = $('#template-vu').html();
|
|
|
|
|
trackData["right-vu"] = trackData["left-vu"];
|
2012-10-21 23:03:46 +00:00
|
|
|
var template = $('#template-session-track').html();
|
2012-12-07 00:28:48 +00:00
|
|
|
var newTrack = context.JK.fillTemplate(template, trackData);
|
2013-01-29 16:30:45 +00:00
|
|
|
$('#session-mytracks-container').append(newTrack);
|
2012-12-07 00:28:48 +00:00
|
|
|
tracks[trackData.clientId] = new context.JK.SessionTrack(trackData.clientId);
|
2012-10-21 23:03:46 +00:00
|
|
|
}
|
|
|
|
|
|
2012-11-03 20:25:23 +00:00
|
|
|
function _userJoinedSession(header, payload) {
|
|
|
|
|
// Just refetch the session and update.
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "GET",
|
|
|
|
|
url: "/api/sessions/" + sessionId
|
|
|
|
|
}).done(function(response) {
|
|
|
|
|
updateSession(response);
|
|
|
|
|
});
|
2012-10-06 16:36:05 +00:00
|
|
|
}
|
|
|
|
|
|
2013-01-31 05:23:30 +00:00
|
|
|
function handleBridgeCallback() {
|
|
|
|
|
var eventName = null;
|
|
|
|
|
var mixerId = null;
|
|
|
|
|
var value = null;
|
|
|
|
|
var tuples = arguments.length / 3;
|
|
|
|
|
for (var i=0; i<tuples; i++) {
|
|
|
|
|
eventName = arguments[3*i];
|
|
|
|
|
mixerId = arguments[(3*i)+1];
|
|
|
|
|
value = arguments[(3*i)+2];
|
|
|
|
|
var vuVal = 0.0;
|
|
|
|
|
if (eventName === 'left_vu' || eventName === 'right_vu') {
|
|
|
|
|
// TODO - no guarantee range will be -80 to 20. Get from the
|
|
|
|
|
// GetControlState for this mixer which returns min/max
|
|
|
|
|
// value is a DB value from -80 to 20. Convert to float from 0.0-1.0
|
|
|
|
|
vuVal = (value + 80) / 100;
|
|
|
|
|
if (eventName === 'left_vu') {
|
2013-01-31 16:32:32 +00:00
|
|
|
mixerId = mixerId + "_vul";
|
2013-01-31 05:23:30 +00:00
|
|
|
} else {
|
2013-01-31 16:32:32 +00:00
|
|
|
mixerId = mixerId + "_vur";
|
2013-01-31 05:23:30 +00:00
|
|
|
}
|
|
|
|
|
_updateVU(mixerId, vuVal);
|
2013-01-31 16:32:32 +00:00
|
|
|
} else {
|
|
|
|
|
// Examples of other events
|
|
|
|
|
// Add media file track: "add", "The_Abyss_4T", 0
|
|
|
|
|
logger.debug('non-vu event: ' + eventName + ',' + mixerId + ',' + value);
|
2013-01-31 05:23:30 +00:00
|
|
|
}
|
2013-01-30 16:50:43 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-06 16:36:05 +00:00
|
|
|
function deleteSession(evt) {
|
2012-12-07 00:28:48 +00:00
|
|
|
var sessionId = $(evt.currentTarget).attr("action-id");
|
2012-10-06 16:36:05 +00:00
|
|
|
if (sessionId) {
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "DELETE",
|
|
|
|
|
url: "/api/sessions/" + sessionId
|
|
|
|
|
}).done(
|
2012-12-07 00:28:48 +00:00
|
|
|
function() { context.location="#/home"; }
|
2012-10-06 16:36:05 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-31 16:32:32 +00:00
|
|
|
function _toggleVisualMuteControl($control, muting) {
|
|
|
|
|
if (muting) {
|
|
|
|
|
$control.removeClass('enabled');
|
|
|
|
|
$control.addClass('muted');
|
|
|
|
|
} else {
|
|
|
|
|
$control.removeClass('muted');
|
|
|
|
|
$control.addClass('enabled');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function _toggleAudioMute(mixerId, muting) {
|
|
|
|
|
context.trackVolumeObject.mute = muting;
|
|
|
|
|
context.jamClient.SessionSetControlState(mixerId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toggleMute(evt) {
|
|
|
|
|
var $control = $(evt.currentTarget);
|
|
|
|
|
var mixerId = $control.attr('mixer-id');
|
2013-02-03 22:47:17 +00:00
|
|
|
fillTrackVolumeObject(currentMixerId);
|
2013-01-31 16:32:32 +00:00
|
|
|
var muting = ($control.hasClass('enabled'));
|
|
|
|
|
_toggleVisualMuteControl($control, muting);
|
|
|
|
|
_toggleAudioMute(mixerId, muting);
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-03 19:48:39 +00:00
|
|
|
function getFaderPercent(eventY, $fader) {
|
|
|
|
|
var faderPosition = $fader.offset();
|
|
|
|
|
var faderHeight = $fader.height();
|
|
|
|
|
var handleValue = faderHeight - (eventY - faderPosition.top);
|
|
|
|
|
var faderPct = Math.round(handleValue/faderHeight * 100);
|
|
|
|
|
if (faderPct < 0) {
|
|
|
|
|
faderPct = 0;
|
|
|
|
|
}
|
|
|
|
|
if (faderPct > 100) {
|
|
|
|
|
faderPct = 100;
|
|
|
|
|
}
|
|
|
|
|
return faderPct;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-03 22:47:17 +00:00
|
|
|
function fillTrackVolumeObject(mixerId) {
|
|
|
|
|
var mixer = null;
|
|
|
|
|
for (var i=0; i<mixers.length; i++) {
|
|
|
|
|
mixer = mixers[i];
|
|
|
|
|
if (mixer.id === mixerId) {
|
|
|
|
|
context.trackVolumeObject.clientID = mixer.client_id;
|
|
|
|
|
context.trackVolumeObject.master = mixer.master;
|
|
|
|
|
context.trackVolumeObject.monitor = mixer.monitor;
|
|
|
|
|
context.trackVolumeObject.mute = mixer.mute;
|
|
|
|
|
context.trackVolumeObject.name = mixer.name;
|
|
|
|
|
context.trackVolumeObject.record = mixer.record;
|
|
|
|
|
context.trackVolumeObject.volL = mixer.volume_left;
|
|
|
|
|
context.trackVolumeObject.volR = mixer.volume_right;
|
|
|
|
|
// trackVolumeObject doesn't have a place for range min/max
|
|
|
|
|
currentMixerRangeMin = mixer.range_low;
|
|
|
|
|
currentMixerRangeMax = mixer.range_high;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-02-03 19:48:39 +00:00
|
|
|
// Given a volumne percent (0-100), set the underlying
|
|
|
|
|
// audio volume level of the passed mixerId to the correct
|
|
|
|
|
// value.
|
|
|
|
|
function setMixerVolume(mixerId, volumePercent) {
|
2013-02-03 22:47:17 +00:00
|
|
|
// The context.trackVolumeObject has been filled with the mixer values
|
|
|
|
|
// that go with mixerId, and the range of that mixer
|
|
|
|
|
// has been set in currentMixerRangeMin-Max.
|
|
|
|
|
// All that needs doing is to translate the incoming percent
|
|
|
|
|
// into the real value ont the sliders range. Set Left/Right
|
|
|
|
|
// volumes on trackVolumeObject, and call SetControlState to stick.
|
|
|
|
|
var sliderRange = currentMixerRangeMax - currentMixerRangeMin;
|
|
|
|
|
volumePercent = volumePercent/100;
|
|
|
|
|
var sliderValue = currentMixerRangeMin + (volumePercent * sliderRange);
|
|
|
|
|
context.trackVolumeObject.volL = sliderValue;
|
|
|
|
|
context.trackVolumeObject.volR = sliderValue;
|
|
|
|
|
context.jamClient.SessionSetControlState(mixerId);
|
2013-02-03 19:48:39 +00:00
|
|
|
}
|
|
|
|
|
|
2013-02-03 00:16:12 +00:00
|
|
|
function faderClick(evt) {
|
2013-02-03 19:48:39 +00:00
|
|
|
evt.stopPropagation();
|
|
|
|
|
if ($draggingFaderHandle) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2013-02-03 00:16:12 +00:00
|
|
|
var $fader = $(evt.currentTarget);
|
|
|
|
|
var $handle = $fader.find('div[control="fader-handle"]');
|
2013-02-03 19:48:39 +00:00
|
|
|
var faderPct = getFaderPercent(evt.clientY, $fader);
|
|
|
|
|
var mixerId = $fader.closest('[mixer-id]').attr('mixer-id');
|
2013-02-03 22:47:17 +00:00
|
|
|
fillTrackVolumeObject(mixerId);
|
2013-02-03 19:48:39 +00:00
|
|
|
setMixerVolume(mixerId, faderPct);
|
|
|
|
|
if (faderPct > 90) { faderPct = 90; } // Visual limit
|
2013-02-03 00:16:12 +00:00
|
|
|
$handle.css('bottom', faderPct + '%');
|
2013-02-03 19:48:39 +00:00
|
|
|
return false;
|
2013-02-03 00:16:12 +00:00
|
|
|
}
|
|
|
|
|
|
2013-02-03 17:50:26 +00:00
|
|
|
function faderHandleDown(evt) {
|
|
|
|
|
evt.stopPropagation();
|
2013-02-03 19:48:39 +00:00
|
|
|
$draggingFaderHandle = $(evt.currentTarget);
|
|
|
|
|
$draggingFader = $draggingFaderHandle.closest('div[control="fader"]');
|
|
|
|
|
currentMixerId = $draggingFader.closest('[mixer-id]').attr('mixer-id');
|
2013-02-03 22:47:17 +00:00
|
|
|
fillTrackVolumeObject(currentMixerId);
|
2013-02-03 19:48:39 +00:00
|
|
|
return false;
|
2013-02-03 17:50:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function tracksMouseUp(evt) {
|
2013-02-03 19:48:39 +00:00
|
|
|
evt.stopPropagation();
|
|
|
|
|
if ($draggingFaderHandle) {
|
|
|
|
|
$draggingFaderHandle = null;
|
2013-02-03 17:50:26 +00:00
|
|
|
$draggingFader = null;
|
2013-02-03 19:48:39 +00:00
|
|
|
currentMixerId = null;
|
2013-02-03 17:50:26 +00:00
|
|
|
}
|
2013-02-03 19:48:39 +00:00
|
|
|
return false;
|
2013-02-03 17:50:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function tracksMouseMove(evt) {
|
2013-02-03 19:48:39 +00:00
|
|
|
// bail out early if there's no in-process drag
|
|
|
|
|
if (!($draggingFaderHandle)) {
|
|
|
|
|
return false;
|
2013-02-03 17:50:26 +00:00
|
|
|
}
|
2013-02-03 19:48:39 +00:00
|
|
|
evt.stopPropagation();
|
|
|
|
|
var faderPct = getFaderPercent(evt.clientY, $draggingFader);
|
|
|
|
|
setMixerVolume(currentMixerId, faderPct);
|
|
|
|
|
if (faderPct > 90) { faderPct = 90; } // Visual limit
|
|
|
|
|
$draggingFaderHandle.css('bottom', faderPct + '%');
|
|
|
|
|
return false;
|
2013-02-03 17:50:26 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-06 16:36:05 +00:00
|
|
|
function events() {
|
|
|
|
|
$('#session-contents').on("click", '[action="delete"]', deleteSession);
|
2013-01-31 16:32:32 +00:00
|
|
|
$('#tracks').on('click', 'div[control="mute"]', toggleMute);
|
2013-02-03 00:16:12 +00:00
|
|
|
$('#tracks').on('click', 'div[control="fader"]', faderClick);
|
2013-02-03 17:50:26 +00:00
|
|
|
$('#tracks').on('mousedown', 'div[control="fader-handle"]', faderHandleDown);
|
2013-02-03 19:48:39 +00:00
|
|
|
$('body').on('mouseup', tracksMouseUp);
|
2013-02-03 17:50:26 +00:00
|
|
|
$('#tracks').on('mousemove', tracksMouseMove);
|
2012-10-06 16:36:05 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-14 15:48:56 +00:00
|
|
|
this.initialize = function() {
|
|
|
|
|
events();
|
2012-12-07 00:28:48 +00:00
|
|
|
var screenBindings = {
|
2012-10-29 15:10:02 +00:00
|
|
|
'beforeShow': beforeShow,
|
2012-10-29 00:37:59 +00:00
|
|
|
'afterShow': afterShow,
|
2012-10-29 15:10:02 +00:00
|
|
|
'beforeHide': beforeHide
|
2012-10-14 15:48:56 +00:00
|
|
|
};
|
|
|
|
|
app.bindScreen('session', screenBindings);
|
2012-12-07 00:28:48 +00:00
|
|
|
app.subscribe(context.JK.MessageType.USER_JOINED_MUSIC_SESSION, _userJoinedSession);
|
2012-10-06 16:36:05 +00:00
|
|
|
};
|
|
|
|
|
|
2012-10-22 02:55:05 +00:00
|
|
|
this.tracks = tracks;
|
|
|
|
|
|
2013-01-30 16:50:43 +00:00
|
|
|
context.JK.HandleBridgeCallback = handleBridgeCallback;
|
|
|
|
|
|
2012-10-06 16:36:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
})(window,jQuery);
|