diff --git a/pandora/edit/migrations/0001_initial.py b/pandora/edit/migrations/0001_initial.py index 3028e2a0b..df5c816cb 100644 --- a/pandora/edit/migrations/0001_initial.py +++ b/pandora/edit/migrations/0001_initial.py @@ -44,11 +44,11 @@ class Migration(migrations.Migration): ('created', models.DateTimeField(auto_now_add=True)), ('modified', models.DateTimeField(auto_now=True)), ('name', models.CharField(max_length=255)), - ('status', models.CharField(default=b'private', max_length=20)), - ('description', models.TextField(default=b'')), + ('status', models.CharField(default='private', max_length=20)), + ('description', models.TextField(default='')), ('rightslevel', models.IntegerField(db_index=True, default=0)), - ('query', oxdjango.fields.DictField(default={b'static': True})), - ('type', models.CharField(default=b'static', max_length=255)), + ('query', oxdjango.fields.DictField(default={'static': True})), + ('type', models.CharField(default='static', max_length=255)), ('icon', models.ImageField(blank=True, default=None, null=True, upload_to=edit.models.get_icon_path)), ('poster_frames', oxdjango.fields.TupleField(default=[], editable=False)), ('subscribed_users', models.ManyToManyField(related_name='subscribed_edits', to=settings.AUTH_USER_MODEL)), diff --git a/pandora/edit/migrations/0003_auto_20170415_1029.py b/pandora/edit/migrations/0003_auto_20170415_1029.py new file mode 100644 index 000000000..a201a0b63 --- /dev/null +++ b/pandora/edit/migrations/0003_auto_20170415_1029.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2017-04-15 10:29 +from __future__ import unicode_literals + +from django.db import migrations, models +import oxdjango.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('edit', '0002_auto_20160219_1537'), + ] + + operations = [ + migrations.RenameField( + model_name='clip', + old_name='volume', + new_name='sortvolume', + ), + migrations.AddField( + model_name='clip', + name='volume', + field=models.FloatField(default=1), + ), + ] diff --git a/pandora/edit/models.py b/pandora/edit/models.py index f846d436f..cebc5c49e 100644 --- a/pandora/edit/models.py +++ b/pandora/edit/models.py @@ -94,6 +94,8 @@ class Edit(models.Model): or round(c.start, 3) >= round(duration, 3) \ or round(c.end, 3) > round(duration, 3): return False + if 'volume' in data: + c.volume = float(data['volume']) c.save() if index is not None: ids.insert(index, c.id) @@ -427,11 +429,12 @@ class Clip(models.Model): start = models.FloatField(default=0) end = models.FloatField(default=0) duration = models.FloatField(default=0) - + volume = models.FloatField(default=1) + hue = models.FloatField(default=0) saturation = models.FloatField(default=0) lightness = models.FloatField(default=0) - volume = models.FloatField(default=0) + sortvolume = models.FloatField(default=0) sortvalue = models.CharField(max_length=1000, null=True, db_index=True) objects = managers.ClipManager() @@ -466,15 +469,16 @@ class Clip(models.Model): if int(end*25) - int(start*25) > 0: self.hue, self.saturation, self.lightness = extract.average_color( self.item.timeline_prefix, self.start, self.end) - self.volume = extract.average_volume(self.item.timeline_prefix, self.start, self.end) + self.sortvolume = extract.average_volume(self.item.timeline_prefix, self.start, self.end) else: self.hue = self.saturation = self.lightness = 0 - self.volume = 0 + self.sortvolume = 0 def json(self, user=None): data = { 'id': self.get_id(), - 'index': self.index + 'index': self.index, + 'volume': self.volume, } if self.annotation: data['annotation'] = self.annotation.public_id diff --git a/pandora/edit/views.py b/pandora/edit/views.py index 6b48290e5..66468684f 100644 --- a/pandora/edit/views.py +++ b/pandora/edit/views.py @@ -102,6 +102,7 @@ def editClip(request, data): id: string, // clip id in: float, // in point in seconds out: float // out point in seconds + volume: float // per clip volume (0-1) } returns {} see: addClips, orderClips, removeClips, sortClips @@ -118,6 +119,8 @@ def editClip(request, data): clip.item = clip.annotation.item clip.annotation = None setattr(clip, {'in': 'start', 'out': 'end'}.get(key), float(data[key])) + if 'volume' in data: + clip.volume = float(data['volume']) if not clip.annotation: duration = clip.item.sort.duration if clip.start >= clip.end or clip.start >= duration or clip.end > duration: @@ -183,6 +186,7 @@ def _order_clips(edit, sort): 'in': 'start', 'out': 'end', 'text': 'sortvalue', + 'volume': 'sortvolume', 'item__sort__item': 'item__sort__public_id', }.get(key, key) order = '%s%s' % (operator, key) diff --git a/static/js/editPanel.js b/static/js/editPanel.js index 89338005a..79c5d25cc 100644 --- a/static/js/editPanel.js +++ b/static/js/editPanel.js @@ -213,6 +213,18 @@ pandora.ui.editPanel = function(isEmbed) { } pandora.api.get({id: clip.item, keys: ['duration']}, function(result) { var clips; + //fixme include in history... + if (data.key == 'volume') { + pandora.api.editClip({ + id: data.id, + volume: data.value + }, function(result) { + edit.clips[Ox.getIndexById(edit.clips, data.id)] = result.data; + Ox.Request.clearCache('sortClips'); + sortClips(updateClips); + }); + return; + } if (data.key == 'out') { data.value = Math.min(data.value, result.data.duration); } diff --git a/static/js/utils.js b/static/js/utils.js index 5f93ae577..c423327f6 100644 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -1197,6 +1197,9 @@ pandora.getClipVideos = function(clip, resolution) { if (clip.id) { item.id = clip.id; } + if (Ox.isNumber(clip.volume)) { + item.volume = clip.volume; + } if ( currentTime <= start && currentTime + clip.durations[i] > start