update video on sort and time code changes

This commit is contained in:
j 2013-07-14 10:57:03 +00:00
parent bd606a6512
commit 1ec946d118
2 changed files with 34 additions and 4 deletions

View file

@ -96,7 +96,7 @@ def editClip(request):
response = json_response() response = json_response()
data = json.loads(request.POST['data']) data = json.loads(request.POST['data'])
clip = get_object_or_404_json(models.Clip, pk=ox.fromAZ(data['id'])) clip = get_object_or_404_json(models.Clip, pk=ox.fromAZ(data['id']))
valid = False valid = True
if clip.edit.editable(request.user): if clip.edit.editable(request.user):
for key in ('in', 'out'): for key in ('in', 'out'):
if key in data: if key in data:

View file

@ -116,8 +116,14 @@ pandora.ui.editPanel = function() {
args['in'] = args.out; args['in'] = args.out;
} }
pandora.api.editClip(args, function(result) { pandora.api.editClip(args, function(result) {
edit.clips[index] = result.data; if (result.status.code == 200) {
that.updateClip(data.id, result.data); edit.clips[index] = result.data;
console.log(index, result.data);
that.updateClip(data.id, result.data);
updateVideos();
} else {
Ox.print('failed to edit clip', result);
}
}); });
}); });
}, },
@ -127,6 +133,7 @@ pandora.ui.editPanel = function() {
ids: data.ids ids: data.ids
}, function() { }, function() {
Ox.Request.clearCache('getEdit'); Ox.Request.clearCache('getEdit');
sortClips(data.ids);
}); });
}, },
muted: function(data) { muted: function(data) {
@ -138,6 +145,7 @@ pandora.ui.editPanel = function() {
clips: Ox.Clipboard.paste(), clips: Ox.Clipboard.paste(),
edit: pandora.user.ui.edit edit: pandora.user.ui.edit
}, function(result) { }, function(result) {
Ox.Request.clearCache('getEdit');
updateClips(edit.clips.concat(result.data.clips)); updateClips(edit.clips.concat(result.data.clips));
}); });
} }
@ -154,6 +162,7 @@ pandora.ui.editPanel = function() {
ids: data.ids, ids: data.ids,
edit: pandora.user.ui.edit edit: pandora.user.ui.edit
}, function(result) { }, function(result) {
Ox.Request.clearCache('getEdit');
updateClips(result.data.clips); updateClips(result.data.clips);
}); });
} }
@ -213,8 +222,15 @@ pandora.ui.editPanel = function() {
}); });
} }
function sortClips(ids) {
edit.clips.forEach(function(clip) {
clip.index = ids.indexOf(clip.id);
});
edit.clips = Ox.sortBy(edit.clips, 'index');
udpateVideos();
}
function updateClips(clips) { function updateClips(clips) {
Ox.Request.clearCache(); // FIXME: too much
edit.clips = clips; edit.clips = clips;
edit.duration = 0; edit.duration = 0;
edit.clips.forEach(function(clip) { edit.clips.forEach(function(clip) {
@ -230,6 +246,20 @@ pandora.ui.editPanel = function() {
} }
function updateVideos() {
edit.duration = 0;
edit.clips.forEach(function(clip) {
clip.position = edit.duration;
edit.duration += clip.duration;
});
that.options({
smallTimelineURL: getSmallTimelineURL(),
video: getVideos()
});
updateSmallTimelineURL();
}
function updateSmallTimelineURL() { function updateSmallTimelineURL() {
var fps = 25; var fps = 25;
Ox.serialForEach(edit.clips, function(clip) { Ox.serialForEach(edit.clips, function(clip) {