expose per clip volume in edits
This commit is contained in:
parent
28f9a01d90
commit
be34383f8c
6 changed files with 58 additions and 9 deletions
|
@ -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)),
|
||||
|
|
26
pandora/edit/migrations/0003_auto_20170415_1029.py
Normal file
26
pandora/edit/migrations/0003_auto_20170415_1029.py
Normal file
|
@ -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),
|
||||
),
|
||||
]
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue