Skip to content

Commit

Permalink
finetuning
Browse files Browse the repository at this point in the history
  • Loading branch information
randomknowledge committed Mar 11, 2013
1 parent 2fcf0d7 commit b49219a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
17 changes: 15 additions & 2 deletions django_webvideo/admin.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# coding: utf-8
from django.contrib import admin
from django.utils.safestring import mark_safe
from django_webvideo.models import WebVideo, VideoScreen, ConvertedVideo
from django_webvideo.settings import get_setting
from django_webvideo.templatetags.webvideo_tags import video_tag
from django.utils.translation import ugettext_lazy as _
from django_webvideo.utils import sizeof_fmt, url_to_edit_object


preview_disclaimer = _("Video is embedded as {codec} only, which is eventually not supported by your webbrowser!")


def get_resized_image(image, width=0, height=0, upscale=True):
from easy_thumbnails.files import get_thumbnailer
from easy_thumbnails.exceptions import InvalidImageFormatError
Expand Down Expand Up @@ -64,8 +68,17 @@ def admin_video_helper(obj=True, for_admin=True):
def admin_video(*args):
obj = args[1 if for_admin else 0]
if isinstance(obj, ConvertedVideo):
return video_tag(obj.original, quality=obj.quality, preload='meta', width='100%', height='auto',
screen_num=2)
return "{disclaimer}{video}".format(
disclaimer=mark_safe(
"<p class='text-error'>{text}</p>".format(
text=preview_disclaimer.format(
codec="<strong>{0}</strong>".format(obj.codec)
)
)
),
video=video_tag(obj.original, quality=obj.quality, preload='meta', width='100%', height='auto',
screen_num=2, codec=obj.codec)
)
else:
return video_tag(obj, quality='max', preload='meta', width='100%', height='auto', screen_num=2)
admin_video.allow_tags = True
Expand Down
11 changes: 6 additions & 5 deletions django_webvideo/templatetags/webvideo_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@register.simple_tag
def video_tag(video, quality='max', width=None, height=None, preload="auto", autoplay=False, controls=True,
attributes="", screen_num=1):
attributes="", screen_num=1, codec='all'):
screen = video.get_screen(screen_num)

converted = video.converted.all()
Expand All @@ -28,10 +28,11 @@ def video_tag(video, quality='max', width=None, height=None, preload="auto", aut

files = []
for conv in converted:
files.append({
'obj': conv.video,
'mime': constants.VIDEO_MIMETYPES.get(conv.codec)
})
if codec == 'all' or codec == conv.codec:
files.append({
'obj': conv.video,
'mime': constants.VIDEO_MIMETYPES.get(conv.codec)
})

return render_to_string("django_webvideo/snippets/video-embed.html", context_instance=Context({
'video': video,
Expand Down

0 comments on commit b49219a

Please sign in to comment.