* VRFS-2484 - wip pausing point; the code should not affect stability because it's mostly jamtrack only related
This commit is contained in:
parent
e8ffb9c27d
commit
0ab7686205
|
|
@ -77,6 +77,7 @@
|
|||
// tell the server we are about to start a recording
|
||||
rest.openJamTrack({id: context.JK.CurrentSessionModel.id(), jam_track_id: jamTrack.id})
|
||||
.done(function(response) {
|
||||
context.jamClient.JamTrackStopPlay();
|
||||
var result = context.jamClient.JamTrackPlay('t');
|
||||
|
||||
logger.debug("JamTrackPlay response: %o", result);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
$ = jQuery
|
||||
context = window
|
||||
context.JK ||= {};
|
||||
|
||||
context.JK.DownloadJamTrack = class SyncViewer
|
||||
constructor: (@app) ->
|
||||
@EVENTS = context.JK.EVENTS
|
||||
@rest = context.JK.Rest()
|
||||
|
||||
init: () =>
|
||||
@root = $($('#template-download-jamtrack').html())
|
||||
|
|
@ -87,7 +87,9 @@
|
|||
"UserMusicInputGroup": 7,
|
||||
"UserChatInputGroup": 8,
|
||||
"PeerAudioInputMusicGroup": 9,
|
||||
"PeerMediaTrackGroup": 10
|
||||
"PeerMediaTrackGroup": 10,
|
||||
"JamTrackGroup": 11,
|
||||
"MetronomeGroup": 12
|
||||
};
|
||||
|
||||
function beforeShow(data) {
|
||||
|
|
@ -599,6 +601,20 @@
|
|||
return foundMixers;
|
||||
}
|
||||
|
||||
function _mixersForGroupIds(groupIds, mixMode) {
|
||||
var foundMixers = [];
|
||||
var mixers = mixMode == MIX_MODES.MASTER ? masterMixers : personalMixers;
|
||||
$.each(mixers, function(index, mixer) {
|
||||
var groupIdLen = groupIds.length;
|
||||
for (var i = 0; i < groupIdLen; i++) {
|
||||
if ( mixer.group_id === groupIds[i]) {
|
||||
foundMixers.push(mixer);
|
||||
}
|
||||
}
|
||||
});
|
||||
return foundMixers;
|
||||
}
|
||||
|
||||
function _getMyVoiceChatMixers() {
|
||||
var mixers = _mixersForGroupId(ChannelGroupIds.AudioInputChatGroup, sessionModel.getMixMode());
|
||||
|
||||
|
|
@ -796,8 +812,8 @@
|
|||
|
||||
function _renderLocalMediaTracks() {
|
||||
|
||||
// first gather all master mode media mixers and peer media mixers
|
||||
var localMediaMixers = _mixersForGroupId(ChannelGroupIds.MediaTrackGroup, MIX_MODES.MASTER);
|
||||
// local media mixers come in different groups (MediaTrack, JamTrack, Metronome), but peer mixers are always PeerMediaTrackGroup
|
||||
var localMediaMixers = _mixersForGroupIds([ChannelGroupIds.MediaTrackGroup, ChannelGroupIds.JamTrackGroup, ChannelGroupIds.MetronomeGroup], MIX_MODES.MASTER);
|
||||
var peerLocalMediaMixers = _mixersForGroupId(ChannelGroupIds.PeerMediaTrackGroup, MIX_MODES.MASTER);
|
||||
|
||||
// with mixer info, we use these to decide what kind of tracks are open in the backend
|
||||
|
|
@ -820,7 +836,7 @@
|
|||
var metronomeTrackMixers = [];
|
||||
var adhocTrackMixers = [];
|
||||
|
||||
|
||||
console.log("_renderLocalMediaTracks", localMediaMixers)
|
||||
function groupByType(mixers) {
|
||||
context._.each(mixers, function(mixer) {
|
||||
var mediaType = mixer.media_type;
|
||||
|
|
@ -869,7 +885,99 @@
|
|||
}
|
||||
|
||||
function renderJamTracks(jamTrackMixers) {
|
||||
logger.error("do not know how to draw jam tracks yet")
|
||||
log.debug("rendering jam tracks")
|
||||
var jamTracks = sessionModel.jamTracks();
|
||||
|
||||
// pluck the 1st mixer, and assume that all other mixers in this group are of the same type (between JamTrack vs Peer)
|
||||
// if it's a locally opened track (JamTrackGroup), then we can say this person is the opener
|
||||
var isOpener = jamTrackMixers[0].group_id == ChannelGroupIds.JamTrackGroup;
|
||||
|
||||
// using the server's info in conjuction with the client's, draw the recording tracks
|
||||
if(jamTracks) {
|
||||
$('.session-recording-name').text(sessionModel.getCurrentSession().jam_track.name);
|
||||
|
||||
var noCorrespondingTracks = false;
|
||||
$.each(jamTrackMixers, function(index, mixer) {
|
||||
var preMasteredClass = "";
|
||||
// find the track or tracks that correspond to the mixer
|
||||
var correspondingTracks = []
|
||||
console.log("mixer", mixer)
|
||||
$.each(jamTracks, function(i, jamTrack) {
|
||||
if(mixer.id.indexOf("L") == 0) {
|
||||
if(mixer.id.substring(1) == jamTrack.id) {
|
||||
correspondingTracks.push(jamTrack);
|
||||
}
|
||||
else {
|
||||
// this should not be possible
|
||||
alert("Invalid state: the recorded track had neither persisted_track_id or persisted_client_id");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if(correspondingTracks.length == 0) {
|
||||
noCorrespondingTracks = true;
|
||||
app.notify({
|
||||
title: "Unable to Open JamTrack",
|
||||
text: "Could not correlate server and client tracks",
|
||||
icon_url: "/assets/content/icon_alert_big.png"});
|
||||
return false;
|
||||
}
|
||||
|
||||
// prune found recorded tracks
|
||||
jamTracks = $.grep(jamTracks, function(value) {
|
||||
return $.inArray(value, correspondingTracks) < 0;
|
||||
});
|
||||
|
||||
var oneOfTheTracks = correspondingTracks[0];
|
||||
var instrumentIcon = context.JK.getInstrumentIcon45(oneOfTheTracks.instrument_id);
|
||||
var photoUrl = "/assets/content/icon_recording.png";
|
||||
|
||||
var name = oneOfTheTracks.part
|
||||
if (!name) {
|
||||
name = oneOfTheTracks.instrument;
|
||||
}
|
||||
|
||||
// Default trackData to participant + no Mixer state.
|
||||
var trackData = {
|
||||
trackId: oneOfTheTracks.id,
|
||||
clientId: oneOfTheTracks.client_id,
|
||||
name: name,
|
||||
instrumentIcon: instrumentIcon,
|
||||
avatar: photoUrl,
|
||||
latency: "good",
|
||||
gainPercent: 0,
|
||||
muteClass: 'muted',
|
||||
mixerId: "",
|
||||
avatarClass : 'avatar-recording',
|
||||
preMasteredClass: ""
|
||||
};
|
||||
|
||||
var gainPercent = percentFromMixerValue(
|
||||
mixer.range_low, mixer.range_high, mixer.volume_left);
|
||||
var muteClass = "enabled";
|
||||
if (mixer.mute) {
|
||||
muteClass = "muted";
|
||||
}
|
||||
trackData.gainPercent = gainPercent;
|
||||
trackData.muteClass = muteClass;
|
||||
trackData.mixerId = mixer.id; // the master mixer controls the volume control for recordings (no personal controls in either master or personal mode)
|
||||
trackData.vuMixerId = mixer.id; // the master mixer controls the VUs for recordings (no personal controls in either master or personal mode)
|
||||
trackData.muteMixerId = mixer.id; // the master mixer controls the mute for recordings (no personal controls in either master or personal mode)
|
||||
|
||||
if(sessionModel.isPersonalMixMode() || !isOpener) {
|
||||
trackData.mediaControlsDisabled = true;
|
||||
trackData.mediaTrackOpener = isOpener;
|
||||
}
|
||||
_addRecordingTrack(trackData);
|
||||
});
|
||||
|
||||
if(!noCorrespondingTracks && jamTracks.length > 0) {
|
||||
logger.error("unable to find all jam tracks against client tracks");
|
||||
app.notify({title:"All tracks not found",
|
||||
text: "Some tracks in the jam tracks are not present in the playback",
|
||||
icon_url: "/assets/content/icon_alert_big.png"})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function renderMetronomeTracks(metronomeTrackMixers) {
|
||||
|
|
@ -881,15 +989,6 @@
|
|||
// get the server's info for the recording
|
||||
var recordedTracks = sessionModel.recordedTracks();
|
||||
|
||||
if(recordedTracks && recordingMixers.length == 0) {
|
||||
// if we are the creator, then rather than raise an error, tell the server the recording is over.
|
||||
// this shoudl only happen if we get temporarily disconnected by forced reload, which isn't a very normal scenario
|
||||
if(sessionModel.getCurrentSession().claimed_recording_initiator_id == context.JK.userMe.id) {
|
||||
closeRecording();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// pluck the 1st mixer, and assume that all other mixers in this group are of the same type (between Local vs Peer)
|
||||
// if it's a locally opened track (MediaTrackGroup), then we can say this person is the opener
|
||||
|
||||
|
|
@ -1834,7 +1933,7 @@
|
|||
if(sessionModel.recordedTracks()) {
|
||||
closeRecording();
|
||||
}
|
||||
else if(sessionModel.jamTrack()) {
|
||||
else if(sessionModel.jamTracks()) {
|
||||
closeJamTrack();
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -78,6 +78,15 @@
|
|||
}
|
||||
}
|
||||
|
||||
function jamTracks() {
|
||||
if(currentSession && currentSession.jam_track) {
|
||||
return currentSession.jam_track.tracks
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function creatorId() {
|
||||
if(!currentSession) {
|
||||
throw "creator is not known"
|
||||
|
|
@ -709,6 +718,7 @@
|
|||
this.start = start;
|
||||
this.setUserTracks = setUserTracks;
|
||||
this.recordedTracks = recordedTracks;
|
||||
this.jamTracks = jamTracks;
|
||||
this.participants = participants;
|
||||
this.joinSession = joinSession;
|
||||
this.leaveCurrentSession = leaveCurrentSession;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
@import "client/common";
|
||||
|
||||
.download-jamtrack {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
script type="text/template" id='template-download-jamtrack'
|
||||
.download-jamtrack
|
||||
|
|
@ -103,7 +103,7 @@
|
|||
|
||||
<!-- recordings -->
|
||||
<div class="session-recordings">
|
||||
<h2>recordings</h2>
|
||||
<h2>other audio</h2>
|
||||
<div class="session-recording-name-wrapper">
|
||||
<div class="session-recording-name left">(No recording loaded)</div>
|
||||
<div class="session-add right">
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
describe "DownloadJamTrack", ->
|
||||
|
||||
beforeEach ->
|
||||
this.fixtures = fixture.load("downoadJamTrack.html", "user_sync_track1.json"); # append these fixtures which were already cached
|
||||
this.server = sinon.fakeServer.create();
|
||||
window.jamClient = sinon.stub()
|
||||
this.downloadJamTrack = new JK.DownloadJamTrack()
|
||||
this.downloadJamTrack.init()
|
||||
$('body').append(this.downloadJamTrack.root)
|
||||
|
||||
afterEach ->
|
||||
this.server.restore();
|
||||
|
||||
it "display state correctly", ->
|
||||
$track = this.syncViewer.createTrack(this.track1)
|
||||
this.syncViewer.updateTrackState($track)
|
||||
|
|
@ -0,0 +1 @@
|
|||
= render "clients/download_jamtrack_templates"
|
||||
|
|
@ -702,7 +702,21 @@ module JamWebsockets
|
|||
if music_session_id.nil?
|
||||
# if this is a reclaim of a connection, but music_session_id comes back null, then we need to check if this connection was IN a music session before.
|
||||
# if so, then we need to tell the others in the session that this user is now departed
|
||||
|
||||
|
||||
unless music_session_upon_reentry.nil? || music_session_upon_reentry.destroyed?
|
||||
|
||||
# if a jamtrack is open and this user is no longer in the session, close it
|
||||
if music_session_upon_reentry.jam_track_initiator == user
|
||||
music_session_upon_reentry.close_jam_track
|
||||
end
|
||||
|
||||
# if a recording is open and this user is no longer in the session, close it
|
||||
if music_session_upon_reentry.claimed_recording_initiator == user
|
||||
music_session_upon_reentry.claimed_recording_stop
|
||||
end
|
||||
|
||||
# handle case that a recording was ongoing - any one leaves, we stop it
|
||||
recording = music_session_upon_reentry.stop_recording
|
||||
unless recording.nil?
|
||||
@log.debug "stopped recording: #{recording.id} because user #{user} reconnected"
|
||||
|
|
|
|||
Loading…
Reference in New Issue