##// END OF EJS Templates
fixed base64 embedding for video on python3...
sukisuki -
Show More
@@ -6,6 +6,7 b''
6
6
7 from __future__ import print_function
7 from __future__ import print_function
8
8
9 import base64
9 import json
10 import json
10 import mimetypes
11 import mimetypes
11 import os
12 import os
@@ -869,14 +870,14 b' class Video(DisplayObject):'
869 mimetype, encoding = mimetypes.guess_type(self.filename)
870 mimetype, encoding = mimetypes.guess_type(self.filename)
870
871
871 video = open(self.filename, 'rb').read()
872 video = open(self.filename, 'rb').read()
872 video_encoded = video.encode('base64')
873 video_encoded = base64.b64encode(video)
873 else:
874 else:
874 video_encoded = self.data
875 video_encoded = self.data
875 mimetype = self.mimetype
876 mimetype = self.mimetype
876 output = """<video controls>
877 output = """<video controls>
877 <source src="data:{0};base64,{1}" type="{0}">
878 <source src="data:{0};base64,{1}" type="{0}">
878 Your browser does not support the video tag.
879 Your browser does not support the video tag.
879 </video>""".format(mimetype, video_encoded)
880 </video>""".format(mimetype, video_encoded.decode('utf-8'))
880 return output
881 return output
881
882
882 def reload(self):
883 def reload(self):
General Comments 0
You need to be logged in to leave comments. Login now