Commit e67057a0 authored by Seb's avatar Seb
Browse files

Switched the ordering of transcodes so transcodes are preferred. Made the...

Switched the ordering of transcodes so transcodes are preferred. Made the regular template tag use the method from the model
parent db19bd9c
...@@ -244,13 +244,15 @@ class AbstractVideo(CollectionMember, TagSearchable): ...@@ -244,13 +244,15 @@ class AbstractVideo(CollectionMember, TagSearchable):
if self.thumbnail: if self.thumbnail:
attrs['poster'] = self.thumbnail.url attrs['poster'] = self.thumbnail.url
mime = mimetypes.MimeTypes()
sources = ["<source src='{0}' type='{1}'>"
.format(self.url, mime.guess_type(self.url)[0])]
transcodes = self.transcodes.exclude(processing=True).filter(error_message__exact='') transcodes = self.transcodes.exclude(processing=True).filter(error_message__exact='')
sources = []
for transcode in transcodes: for transcode in transcodes:
sources.append("<source src='{0}' type='video/{1}' >".format(transcode.url, transcode.media_format.name)) sources.append("<source src='{0}' type='video/{1}' >".format(transcode.url, transcode.media_format.name))
mime = mimetypes.MimeTypes()
sources.append("<source src='{0}' type='{1}'>"
.format(self.url, mime.guess_type(self.url)[0]))
sources.append("<p>Sorry, your browser doesn't support playback for this video</p>") sources.append("<p>Sorry, your browser doesn't support playback for this video</p>")
return mark_safe( return mark_safe(
"<video {0}>\n{1}\n</video>".format(flatatt(attrs), "\n".join(sources))) "<video {0}>\n{1}\n</video>".format(flatatt(attrs), "\n".join(sources)))
......
...@@ -39,16 +39,4 @@ class VideoNode(template.Node): ...@@ -39,16 +39,4 @@ class VideoNode(template.Node):
if not video: if not video:
raise template.TemplateSyntaxError("video tag requires a Video object as the first parameter") raise template.TemplateSyntaxError("video tag requires a Video object as the first parameter")
if video.thumbnail: return video.video_tag(self.attrs)
self.attrs['poster'] = video.thumbnail.url
mime = mimetypes.MimeTypes()
sources = ["<source src='{0}' type='{1}'>"
.format(video.url, mime.guess_type(video.url)[0])]
transcodes = video.transcodes.exclude(processing=True).filter(error_message__exact='')
for transcode in transcodes:
sources.append("<source src='{0}' type='video/{1}' >".format(transcode.url, transcode.media_format.name))
sources.append("<p>Sorry, your browser doesn't support playback for this video</p>")
return mark_safe(
"<video {0}>{1}</video>".format(flatatt(self.attrs), "\n".join(sources)))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment