This commit is contained in:
rolux 2011-10-22 10:19:24 +00:00
commit 3ac27ac27a
11 changed files with 253 additions and 210 deletions

View file

@ -10,7 +10,7 @@
<Location /> <Location />
XSendFile on XSendFile on
XSendFileAllowAbove on XSendFilePath __PREFIX__
</Location> </Location>
Alias /.bzr __PREFIX__/.bzr Alias /.bzr __PREFIX__/.bzr

View file

@ -118,13 +118,7 @@ class Annotation(models.Model):
if not self.clip and not self.layer.private or \ if not self.clip and not self.layer.private or \
(self.clip and not self.layer.private and \ (self.clip and not self.layer.private and \
self.start != self.clip.start or self.end != self.clip.end): self.start != self.clip.start or self.end != self.clip.end):
self.clip, created = Clip.get_or_create(self.item, self.start, self.end)
self.clip, created = Clip.objects.get_or_create(item=self.item,
start=self.start,
end=self.end)
if created:
clip = Clip.objects.get(pk=self.clip.pk)
clip.save()
super(Annotation, self).save(*args, **kwargs) super(Annotation, self).save(*args, **kwargs)

View file

@ -288,7 +288,8 @@ def average_color(prefix, start=0, end=0):
if end: if end:
start = int(start * 25) start = int(start * 25)
end = int(end * 25) end = int(end * 25)
for image in sorted(glob("%s.%d.*.png" % (prefix, height))): timelines = sorted(filter(lambda t: t!= '%s%sp.png'%(prefix,height), glob("%s%sp*.png"%(prefix, height))))
for image in timelines:
start_offset = 0 start_offset = 0
timeline = Image.open(image) timeline = Image.open(image)
frames += timeline.size[0] frames += timeline.size[0]
@ -334,7 +335,8 @@ def cuts(prefix):
height = 64 height = 64
width = 1500 width = 1500
pixels = [] pixels = []
for image in sorted(glob("%s.%d.*.png" % (prefix, height))): timelines = sorted(filter(lambda t: t!= '%s%sp.png'%(prefix,height), glob("%s%sp*.png"%(prefix, height))))
for image in timelines:
timeline = Image.open(image) timeline = Image.open(image)
frames += timeline.size[0] frames += timeline.size[0]
pixels.append(timeline.load()) pixels.append(timeline.load())
@ -418,7 +420,7 @@ def timeline_strip(item, cuts, info, prefix):
if len(line_image) > frame: if len(line_image) > frame:
timeline_image.paste(line_image[frame], (x, 0)) timeline_image.paste(line_image[frame], (x, 0))
if x == timeline_width - 1: if x == timeline_width - 1:
timeline_file = '%sstrip.64.%04d.png' % (prefix, i) timeline_file = '%sStrip64p%04d.png' % (prefix, i)
if _debug: if _debug:
print 'writing', timeline_file print 'writing', timeline_file
timeline_image.save(timeline_file) timeline_image.save(timeline_file)

View file

@ -75,7 +75,6 @@ class File(models.Model):
def set_state(self): def set_state(self):
self.path = self.create_path() self.path = self.create_path()
self.sort_path= utils.sort_string(self.path)
if not os.path.splitext(self.path)[-1] in ( if not os.path.splitext(self.path)[-1] in (
'.srt', '.rar', '.sub', '.idx', '.txt', '.jpg', '.png', '.nfo') \ '.srt', '.rar', '.sub', '.idx', '.txt', '.jpg', '.png', '.nfo') \
@ -135,8 +134,9 @@ class File(models.Model):
self.is_subtitle = False self.is_subtitle = False
self.type = self.get_type() self.type = self.get_type()
info = ox.parse_movie_path(self.path) if self.instances.count()>0:
self.language = info['language'] info = ox.parse_movie_path(self.path)
self.language = info['language']
self.part = self.get_part() self.part = self.get_part()
if self.type not in ('audio', 'video'): if self.type not in ('audio', 'video'):
@ -145,6 +145,7 @@ class File(models.Model):
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
if self.auto: if self.auto:
self.set_state() self.set_state()
self.sort_path= utils.sort_string(self.path)
if self.is_subtitle: if self.is_subtitle:
self.available = self.data and True or False self.available = self.data and True or False
else: else:
@ -441,6 +442,9 @@ class Stream(models.Model):
duration = models.FloatField(default=0) duration = models.FloatField(default=0)
aspect_ratio = models.FloatField(default=0) aspect_ratio = models.FloatField(default=0)
cuts = fields.TupleField(default=[])
color = fields.TupleField(default=[])
@property @property
def timeline_prefix(self): def timeline_prefix(self):
return os.path.join(settings.MEDIA_ROOT, self.path(), 'timeline') return os.path.join(settings.MEDIA_ROOT, self.path(), 'timeline')
@ -483,6 +487,9 @@ class Stream(models.Model):
def make_timeline(self): def make_timeline(self):
if self.available and not self.source: if self.available and not self.source:
extract.timeline(self.video.path, self.timeline_prefix) extract.timeline(self.video.path, self.timeline_prefix)
self.cuts = tuple(extract.cuts(self.timeline_prefix))
self.color = tuple(extract.average_color(self.timeline_prefix))
self.save()
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
if self.video and not self.info: if self.video and not self.info:

View file

@ -3,16 +3,18 @@
from celery.decorators import task from celery.decorators import task
import ox import ox
from item.models import get_item
from django.conf import settings from django.conf import settings
from item.models import get_item, Item
import item.tasks
import models import models
_INSTANCE_KEYS = ('mtime', 'path') _INSTANCE_KEYS = ('mtime', 'path')
def get_or_create_item(volume, info, user): def get_or_create_item(volume, info, user):
item_info = ox.parse_movie_info(info['path']) item_info = ox.parse_movie_path(info['path'])
return get_item(item_info, user) return get_item(item_info, user)
def get_or_create_file(volume, f, user, item=None): def get_or_create_file(volume, f, user, item=None):
@ -67,17 +69,23 @@ def update_files(user, volume, files):
user = models.User.objects.get(username=user) user = models.User.objects.get(username=user)
volume, created = models.Volume.objects.get_or_create(user=user, name=volume) volume, created = models.Volume.objects.get_or_create(user=user, name=volume)
all_files = [] all_files = []
#ignore extras etc,
#imdb stlye is L/Last, First/Title (Year)/Title.. 4
#otherwise T/Title (Year)/Title... 3
folder_depth = settings.USE_IMDB and 4 or 3
for f in files: for f in files:
#ignore extras etc,
#imdb stlye is L/Last, First/Title (Year)/Title.. 4
#otherwise T/Title (Year)/Title... 3
folder_depth = settings.USE_IMDB and 4 or 3
if len(f['path'].split('/')) == folder_depth: if len(f['path'].split('/')) == folder_depth:
all_files.append(f['oshash']) all_files.append(f['oshash'])
update_or_create_instance(volume, f) update_or_create_instance(volume, f)
#remove deleted files #remove deleted files
models.Instance.objects.filter(volume=volume).exclude(file__oshash__in=all_files).delete() removed = models.Instance.objects.filter(volume=volume).exclude(file__oshash__in=all_files)
ids = [i['itemId'] for i in Item.objects.filter(
files__instances__in=removed.filter(file__selected=True)).distinct().values('itemId')]
removed.delete()
for i in ids:
i = Item.objects.get(itemId=i)
i.update_selected()
@task(queue="encoding") @task(queue="encoding")
def process_stream(fileId): def process_stream(fileId):

View file

@ -8,6 +8,7 @@ from django.conf import settings
from archive import extract from archive import extract
import managers import managers
class Clip(models.Model): class Clip(models.Model):
''' '''
CREATE INDEX clip_clip_title_idx ON clip_clip (title ASC NULLS LAST); CREATE INDEX clip_clip_title_idx ON clip_clip (title ASC NULLS LAST);
@ -20,7 +21,7 @@ class Clip(models.Model):
created = models.DateTimeField(auto_now_add=True) created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True) modified = models.DateTimeField(auto_now=True)
public_id = models.CharField(max_length=128, unique=True, null=True) public_id = models.CharField(max_length=128, unique=True)
item = models.ForeignKey('item.Item', related_name='clips') item = models.ForeignKey('item.Item', related_name='clips')
@ -52,7 +53,7 @@ class Clip(models.Model):
self.title = self.item.sort.title self.title = self.item.sort.title
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
self.public_id = u"%s/%s-%s" %(self.item.itemId, self.start, self.end) self.public_id = u"%s/%s-%s" %(self.item.itemId, float(self.start), float(self.end))
if self.duration != self.end - self.start: if self.duration != self.end - self.start:
self.update_calculated_values() self.update_calculated_values()
super(Clip, self).save(*args, **kwargs) super(Clip, self).save(*args, **kwargs)
@ -90,6 +91,21 @@ class Clip(models.Model):
j[key] = self.item.get(key) j[key] = self.item.get(key)
return j return j
def __unicode__(self): @classmethod
return u"%s/%s-%s" %(self.item, self.start, self.end) def get_or_create(cls, item, start, end):
start = float(start)
end = float(end)
public_id = u"%s/%s-%s" %(item.itemId, start, end)
qs = cls.objects.filter(public_id=public_id)
if qs.count() == 0:
clip = Clip(item=item, start=start, end=end, public_id=public_id)
clip.save()
created = True
else:
clip = qs[0]
created = False
return clip, created
def __unicode__(self):
return self.public_id

View file

@ -387,7 +387,7 @@ class Item(models.Model):
layers = {} layers = {}
for l in Layer.objects.all(): for l in Layer.objects.all():
ll = layers.setdefault(l.name, []) ll = layers.setdefault(l.name, [])
qs = Annotation.objects.filter(layer=l, item=self).select_related() qs = Annotation.objects.filter(layer=l, item=self)
if l.name == 'subtitles': if l.name == 'subtitles':
qs = qs.exclude(value='') qs = qs.exclude(value='')
if l.private: if l.private:
@ -850,8 +850,22 @@ class Item(models.Model):
def update_timeline(self, force=False): def update_timeline(self, force=False):
streams = self.streams() streams = self.streams()
self.make_timeline() self.make_timeline()
self.data['cuts'] = extract.cuts(self.timeline_prefix) if streams.count() == 1:
self.data['color'] = extract.average_color(self.timeline_prefix) self.data['color'] = streams[0].color
self.data['cuts'] = streams[0].cuts
else:
#self.data['color'] = extract.average_color(self.timeline_prefix)
#self.data['cuts'] = extract.cuts(self.timeline_prefix)
self.data['cuts'] = []
offset = 0
color = [0, 0, 0]
n = streams.count()
for s in streams:
for c in s.cuts:
self.data['cuts'].append(c+offset)
color = map(lambda a,b: (a+b)/n, color,ox.image.getRGB(s.color))
offset += s.duration
self.data['color'] = ox.image.getHSL(color)
#extract.timeline_strip(self, self.data['cuts'], stream.info, self.timeline_prefix[:-8]) #extract.timeline_strip(self, self.data['cuts'], stream.info, self.timeline_prefix[:-8])
self.select_frame() self.select_frame()
self.make_local_poster() self.make_local_poster()

View file

@ -8,8 +8,12 @@ import Image
import ox import ox
def getTiles(timeline_prefix, height=64):
files = glob('%s%sp*.png' % (timeline_prefix, height))
return sorted(filter(lambda f: f!='%s%sp.png' % (timeline_prefix, height), files))
def loadTimeline(timeline_prefix, height=64): def loadTimeline(timeline_prefix, height=64):
files = sorted(glob('%s%sp*.png' % (timeline_prefix, height))) files = getTiles(timeline_prefix, height)
f = Image.open(files[0]) f = Image.open(files[0])
width = f.size[0] width = f.size[0]
f = Image.open(files[-1]) f = Image.open(files[-1])
@ -23,7 +27,7 @@ def loadTimeline(timeline_prefix, height=64):
return timeline return timeline
def makeTiles(timeline_prefix, height=16, width=3600): def makeTiles(timeline_prefix, height=16, width=3600):
files = glob('%s64p*.png' % timeline_prefix) files = getTiles(timeline_prefix, 64)
fps = 25 fps = 25
part_step = 60 part_step = 60
output_width = width output_width = width
@ -53,7 +57,7 @@ def makeTimelineOverview(timeline_prefix, width, inpoint=0, outpoint=0, duration
timeline_file = '%s%sp.png' % (timeline_prefix, height) timeline_file = '%s%sp.png' % (timeline_prefix, height)
if outpoint > 0: if outpoint > 0:
timeline_file = '%s.overview.%s.%d-%d.png' % (timeline_prefix, height, inpoint, outpoint) timeline_file = '%s%sp.%d-%d.png' % (timeline_prefix, height, inpoint, outpoint)
timeline = loadTimeline(timeline_prefix) timeline = loadTimeline(timeline_prefix)
duration = timeline.size[0] duration = timeline.size[0]
@ -70,14 +74,17 @@ def makeTimelineOverview(timeline_prefix, width, inpoint=0, outpoint=0, duration
timeline = timeline.crop((inpoint, 0, outpoint, timeline.size[1])).resize((width, height), Image.ANTIALIAS) timeline = timeline.crop((inpoint, 0, outpoint, timeline.size[1])).resize((width, height), Image.ANTIALIAS)
timeline.save(timeline_file) timeline.save(timeline_file)
def join_timelines(timelines, prefix): def join_timelines(timelines, prefix):
height = 64 height = 64
width = 1500 width = 1500
ox.makedirs(os.path.dirname(prefix))
for f in glob('%s*'%prefix):
os.unlink(f)
tiles = [] tiles = []
for timeline in timelines: for timeline in timelines:
tiles += sorted(glob('%s%sp*.png'%(timeline, height))) tiles += getTiles(timeline, height)
timeline = Image.new("RGB", (2 * width, height)) timeline = Image.new("RGB", (2 * width, height))
@ -99,7 +106,6 @@ def join_timelines(timelines, prefix):
timeline_name = '%s%sp%04d.png' % (prefix, height, i) timeline_name = '%s%sp%04d.png' % (prefix, height, i)
timeline.crop((0, 0, pos, height)).save(timeline_name) timeline.crop((0, 0, pos, height)).save(timeline_name)
ox.makedirs(os.path.dirname(prefix))
makeTiles(prefix, 16, 3600) makeTiles(prefix, 16, 3600)
makeTimelineOverview(prefix, 1920, height=16) makeTimelineOverview(prefix, 1920, height=16)
makeTimelineOverview(prefix, 1920, height=64) makeTimelineOverview(prefix, 1920, height=64)

View file

@ -59,7 +59,7 @@ def addPlace(request):
value = tuple(value) value = tuple(value)
setattr(place, key, value) setattr(place, key, value)
place.save() place.save()
#tasks.update_matches.delay(place.id) tasks.update_matches.delay(place.id)
response = json_response(place.json()) response = json_response(place.json())
else: else:
response = json_response(status=403, response = json_response(status=403,

View file

@ -64,7 +64,6 @@ def get_ui(user_ui, user=None):
ui = updateUI(ui, user_ui) ui = updateUI(ui, user_ui)
if not 'lists' in ui: if not 'lists' in ui:
ui['lists'] = {} ui['lists'] = {}
ui['lists'][''] = copy.deepcopy(config['user']['ui']['lists'][''])
def add(lists, section): def add(lists, section):
ids = [] ids = []

View file

@ -6,7 +6,8 @@ pandora.ui.item = function() {
pandora.api.get({ pandora.api.get({
id: pandora.user.ui.item, id: pandora.user.ui.item,
keys: [] keys: ['video', 'timeline'].indexOf(pandora.user.ui.itemView)>-1 ?
[ 'cuts', 'duration', 'layers', 'parts', 'rendered', 'size', 'title', 'videoRatio'] : []
}, pandora.user.level == 'admin' && pandora.user.ui.itemView == 'info' ? 0 : -1, function(result) { }, pandora.user.level == 'admin' && pandora.user.ui.itemView == 'info' ? 0 : -1, function(result) {
if (result.status.code == 200) { if (result.status.code == 200) {
@ -102,190 +103,186 @@ pandora.ui.item = function() {
); );
} else if (pandora.user.ui.itemView == 'video') { } else if (pandora.user.ui.itemView == 'video') {
pandora.api.get({id: pandora.user.ui.item, keys: ['layers']}, function(r) { // fixme: duplicated
// fixme: duplicated var clipsQuery = pandora.getClipsQuery(),
var clipsQuery = pandora.getClipsQuery(), isClipsQuery = !!clipsQuery.conditions.length,
isClipsQuery = !!clipsQuery.conditions.length, layers = [],
layers = [], video = {};
video = {}; pandora.site.layers.forEach(function(layer, i) {
pandora.site.layers.forEach(function(layer, i) { layers[i] = Ox.extend({}, layer, {items: result.data.layers[layer.id]});
layers[i] = Ox.extend({}, layer, {items: r.data.layers[layer.id]});
});
pandora.site.video.resolutions.forEach(function(resolution) {
video[resolution] = Ox.range(result.data.parts).map(function(i) {
return '/' + pandora.user.ui.item + '/'
+ resolution + 'p' + (i + 1) + '.' + pandora.user.videoFormat;
});
});
//
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.player = Ox.VideoPanelPlayer({
annotationsSize: pandora.user.ui.annotationsSize,
cuts: result.data.cuts || [],
duration: result.data.duration,
find: isClipsQuery ? clipsQuery.conditions[0].value : '',
getTimelineImageURL: function(i) {
return '/' + pandora.user.ui.item + '/timeline64p' + i + '.png';
},
height: pandora.$ui.contentPanel.size(1),
'in': pandora.user.ui.videoPoints[pandora.user.ui.item]['in'],
muted: pandora.user.ui.videoMuted,
out: pandora.user.ui.videoPoints[pandora.user.ui.item].out,
position: pandora.user.ui.videoPoints[pandora.user.ui.item].position,
scaleToFill: pandora.user.ui.videoScale == 'fill',
showAnnotations: pandora.user.ui.showAnnotations,
showControls: pandora.user.ui.showControls,
subtitles: r.data.layers.subtitles ?
r.data.layers.subtitles.map(function(subtitle) {
return {'in': subtitle['in'], out: subtitle.out, text: subtitle.value};
}) : [],
tooltips: true,
timeline: '/' + pandora.user.ui.item + '/timeline16p.png',
video: video,
volume: pandora.user.ui.videoVolume,
width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1
}).bindEvent({
muted: function(data) {
pandora.UI.set('muted', data.muted);
},
position: function(data) {
pandora.UI.set('videoPoints.' + pandora.user.ui.item + '.position', data.position);
},
resizeannotations: function(data) {
pandora.UI.set('annotationsSize', data.annotationsSize);
},
scale: function(data) {
pandora.UI.set('videoScale', data.scale);
},
toggleannotations: function(data) {
pandora.UI.set('showAnnotations', data.showAnnotations);
},
togglecontrols: function(data) {
pandora.UI.set('showControls', data.showControls);
},
volume: function(data) {
pandora.UI.set('volume', data.volume);
},
pandora_showannotations: function(data) {
pandora.$ui.player.options({showAnnotations: data.value});
}
}));
}); });
pandora.site.video.resolutions.forEach(function(resolution) {
video[resolution] = Ox.range(result.data.parts).map(function(i) {
return '/' + pandora.user.ui.item + '/'
+ resolution + 'p' + (i + 1) + '.' + pandora.user.videoFormat;
});
});
//
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.player = Ox.VideoPanelPlayer({
annotationsSize: pandora.user.ui.annotationsSize,
cuts: result.data.cuts || [],
duration: result.data.duration,
find: isClipsQuery ? clipsQuery.conditions[0].value : '',
getTimelineImageURL: function(i) {
return '/' + pandora.user.ui.item + '/timeline64p' + i + '.png';
},
height: pandora.$ui.contentPanel.size(1),
'in': pandora.user.ui.videoPoints[pandora.user.ui.item]['in'],
muted: pandora.user.ui.videoMuted,
out: pandora.user.ui.videoPoints[pandora.user.ui.item].out,
position: pandora.user.ui.videoPoints[pandora.user.ui.item].position,
scaleToFill: pandora.user.ui.videoScale == 'fill',
showAnnotations: pandora.user.ui.showAnnotations,
showControls: pandora.user.ui.showControls,
subtitles: result.data.layers.subtitles ?
result.data.layers.subtitles.map(function(subtitle) {
return {'in': subtitle['in'], out: subtitle.out, text: subtitle.value};
}) : [],
tooltips: true,
timeline: '/' + pandora.user.ui.item + '/timeline16p.png',
video: video,
volume: pandora.user.ui.videoVolume,
width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1
}).bindEvent({
muted: function(data) {
pandora.UI.set('muted', data.muted);
},
position: function(data) {
pandora.UI.set('videoPoints.' + pandora.user.ui.item + '.position', data.position);
},
resizeannotations: function(data) {
pandora.UI.set('annotationsSize', data.annotationsSize);
},
scale: function(data) {
pandora.UI.set('videoScale', data.scale);
},
toggleannotations: function(data) {
pandora.UI.set('showAnnotations', data.showAnnotations);
},
togglecontrols: function(data) {
pandora.UI.set('showControls', data.showControls);
},
volume: function(data) {
pandora.UI.set('volume', data.volume);
},
pandora_showannotations: function(data) {
pandora.$ui.player.options({showAnnotations: data.value});
}
}));
} else if (pandora.user.ui.itemView == 'timeline') { } else if (pandora.user.ui.itemView == 'timeline') {
pandora.api.get({id: pandora.user.ui.item, keys: ['layers']}, function(r) { var clipsQuery = pandora.getClipsQuery(),
var clipsQuery = pandora.getClipsQuery(), isClipsQuery = !!clipsQuery.conditions.length,
isClipsQuery = !!clipsQuery.conditions.length, layers = [],
layers = [], video = {};
video = {}; pandora.site.layers.forEach(function(layer) {
pandora.site.layers.forEach(function(layer) { layers.push(Ox.extend({items: result.data.layers[layer.id]}, layer));
layers.push(Ox.extend({items: r.data.layers[layer.id]}, layer)); });
pandora.site.video.resolutions.forEach(function(resolution) {
video[resolution] = Ox.range(result.data.parts).map(function(i) {
return '/' + pandora.user.ui.item + '/'
+ resolution + 'p' + (i + 1) + '.' + pandora.user.videoFormat;
}); });
pandora.site.video.resolutions.forEach(function(resolution) { });
video[resolution] = Ox.range(result.data.parts).map(function(i) { pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.editor = Ox.VideoEditor({
return '/' + pandora.user.ui.item + '/' annotationsSize: pandora.user.ui.annotationsSize,
+ resolution + 'p' + (i + 1) + '.' + pandora.user.videoFormat; cuts: result.data.cuts || [],
duration: result.data.duration,
find: isClipsQuery ? clipsQuery.conditions[0].value : '',
getFrameURL: function(position) {
return '/' + pandora.user.ui.item + '/' + Ox.last(pandora.site.video.resolutions) + 'p' + position + '.jpg';
},
getLargeTimelineImageURL: function(i) {
return '/' + pandora.user.ui.item + '/timeline64p' + i + '.png';
},
getSmallTimelineImageURL: function(i) {
return '/' + pandora.user.ui.item + '/timeline16p' + i + '.png';
},
height: pandora.$ui.contentPanel.size(1),
id: 'editor',
'in': pandora.user.ui.videoPoints[pandora.user.ui.item]['in'],
layers: layers,
muted: pandora.user.ui.videoMuted,
out: pandora.user.ui.videoPoints[pandora.user.ui.item].out,
position: pandora.user.ui.videoPoints[pandora.user.ui.item].position,
posterFrame: parseInt(video.duration / 2),
showAnnotations: pandora.user.ui.showAnnotations,
showLargeTimeline: true,
// fixme: layers have value, subtitles has text?
subtitles: result.data.layers.subtitles ?
result.data.layers.subtitles.map(function(subtitle) {
return {'in': subtitle['in'], out: subtitle.out, text: subtitle.value};
}) : [],
tooltips: true,
video: video,
videoRatio: result.data.videoRatio,
videoSize: pandora.user.ui.videoSize,
width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1
}).bindEvent({
points: function(data) {
pandora.UI.set('videoPoints.' + pandora.user.ui.item, {
'in': data['in'],
out: data.out,
position: pandora.user.ui.videoPoints[pandora.user.ui.item].position
}); });
}); },
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.editor = Ox.VideoEditor({ position: function(data) {
annotationsSize: pandora.user.ui.annotationsSize, pandora.UI.set('videoPoints.' + pandora.user.ui.item + '.position', data.position);
cuts: result.data.cuts || [], },
duration: result.data.duration, resize: function(data) {
find: isClipsQuery ? clipsQuery.conditions[0].value : '', Ox.print('RESIZE!!', data.size)
getFrameURL: function(position) {
return '/' + pandora.user.ui.item + '/' + Ox.last(pandora.site.video.resolutions) + 'p' + position + '.jpg';
},
getLargeTimelineImageURL: function(i) {
return '/' + pandora.user.ui.item + '/timeline64p' + i + '.png';
},
getSmallTimelineImageURL: function(i) {
return '/' + pandora.user.ui.item + '/timeline16p' + i + '.png';
},
height: pandora.$ui.contentPanel.size(1),
id: 'editor',
'in': pandora.user.ui.videoPoints[pandora.user.ui.item]['in'],
layers: layers,
muted: pandora.user.ui.videoMuted,
out: pandora.user.ui.videoPoints[pandora.user.ui.item].out,
position: pandora.user.ui.videoPoints[pandora.user.ui.item].position,
posterFrame: parseInt(video.duration / 2),
showAnnotations: pandora.user.ui.showAnnotations,
showLargeTimeline: true,
// fixme: layers have value, subtitles has text?
subtitles: r.data.layers.subtitles ?
r.data.layers.subtitles.map(function(subtitle) {
return {'in': subtitle['in'], out: subtitle.out, text: subtitle.value};
}) : [],
tooltips: true,
video: video,
videoRatio: result.data.videoRatio,
videoSize: pandora.user.ui.videoSize,
width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1
}).bindEvent({
points: function(data) {
pandora.UI.set('videoPoints.' + pandora.user.ui.item, {
'in': data['in'],
out: data.out,
position: pandora.user.ui.videoPoints[pandora.user.ui.item].position
});
},
position: function(data) {
pandora.UI.set('videoPoints.' + pandora.user.ui.item + '.position', data.position);
},
resize: function(data) {
Ox.print('RESIZE!!', data.size)
pandora.$ui.editor.options({
height: data.size
});
},
resizeend: function(data) {
pandora.UI.set({annotationsSize: data.size});
},
togglesize: function(data) {
pandora.UI.set({videoSize: data.size});
},
addannotation: function(data) {
Ox.print('addAnnotation', data);
data.item = pandora.user.ui.item;
data.value = 'Click to edit';
pandora.api.addAnnotation(data, function(result) {
pandora.$ui.editor.addAnnotation(data.layer, result.data);
});
},
removeannotations: function(data) {
pandora.api.removeAnnotations(data, function(result) {
//fixme: check for errors
pandora.$ui.editor.removeAnnotations(data.layer, data.ids);
});
},
toggleannotations: function(data) {
pandora.UI.set('showAnnotations', data.showAnnotations);
},
updateannotation: function(data) {
//fixme: check that edit was successfull
pandora.api.editAnnotation(data, function(result) {
Ox.print('done updateAnnotation', result);
});
},
pandora_showannotations: function(data) {
pandora.$ui.editor.options({showAnnotations: data.value});
}
}));
that.bindEvent('resize', function(data) {
//Ox.print('resize item', data)
pandora.$ui.editor.options({ pandora.$ui.editor.options({
height: data.size height: data.size
}); });
}); },
/* resizeend: function(data) {
pandora.$ui.rightPanel.bindEvent('resize', function(data) { pandora.UI.set({annotationsSize: data.size});
Ox.print('... rightPanel resize', data, pandora.$ui.timelinePanel.size(1)) },
pandora.$ui.editor.options({ togglesize: function(data) {
width: data - pandora.$ui.timelinePanel.size(1) - 1 pandora.UI.set({videoSize: data.size});
},
addannotation: function(data) {
Ox.print('addAnnotation', data);
data.item = pandora.user.ui.item;
data.value = 'Click to edit';
pandora.api.addAnnotation(data, function(result) {
pandora.$ui.editor.addAnnotation(data.layer, result.data);
}); });
},
removeannotations: function(data) {
pandora.api.removeAnnotations(data, function(result) {
//fixme: check for errors
pandora.$ui.editor.removeAnnotations(data.layer, data.ids);
});
},
toggleannotations: function(data) {
pandora.UI.set('showAnnotations', data.showAnnotations);
},
updateannotation: function(data) {
//fixme: check that edit was successfull
pandora.api.editAnnotation(data, function(result) {
Ox.print('done updateAnnotation', result);
});
},
pandora_showannotations: function(data) {
pandora.$ui.editor.options({showAnnotations: data.value});
}
}));
that.bindEvent('resize', function(data) {
//Ox.print('resize item', data)
pandora.$ui.editor.options({
height: data.size
}); });
*/
}); });
/*
pandora.$ui.rightPanel.bindEvent('resize', function(data) {
Ox.print('... rightPanel resize', data, pandora.$ui.timelinePanel.size(1))
pandora.$ui.editor.options({
width: data - pandora.$ui.timelinePanel.size(1) - 1
});
});
*/
} else if (pandora.user.ui.itemView == 'map') { } else if (pandora.user.ui.itemView == 'map') {
pandora.$ui.contentPanel.replaceElement(1, pandora.ui.navigationView('map', result.data.videoRatio)); pandora.$ui.contentPanel.replaceElement(1, pandora.ui.navigationView('map', result.data.videoRatio));