Skip to content

Commit

Permalink
Update _show.py
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimpoutaraud committed Jun 8, 2022
1 parent 29947bf commit 7c7cfc5
Showing 1 changed file with 5 additions and 24 deletions.
29 changes: 5 additions & 24 deletions musicalgestures/_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
from matplotlib import pyplot as plt
from IPython.display import Image, display
# try:
# from IPython.display import Video
from IPython.display import HTML
from base64 import b64encode
from IPython.display import Video
# except:
# from IPython.core.display import Video
# from base64 import b64encode
Expand Down Expand Up @@ -91,30 +89,13 @@ def show(file, width=640, height=480, mode='windowed', title='Untitled', parent=
if file_dir == cwd:
video_to_display = os.path.relpath(
video_to_display, os.getcwd()).replace('\\', '/')

mp4 = open(video_to_display,'rb').read()
data_url = "data:video/mp4;base64," + b64encode(mp4).decode()
HTML(f"""
<video width={video_width} height={video_height} controls>
<source src="%s" type="video/mp4">
</video>
""" % data_url)
# display(Video(video_to_display,
# width=video_width, height=video_height))
display(Video(video_to_display,
width=video_width, height=video_height))
else:
video_to_display = os.path.relpath(
video_to_display, os.getcwd()).replace('\\', '/')

mp4 = open(video_to_display,'rb').read()
data_url = "data:video/mp4;base64," + b64encode(mp4).decode()
HTML(f"""
<video width={video_width} height={video_height} controls>
<source src="%s" type="video/mp4">
</video>
""" % data_url)

# display(Video(video_to_display, width=video_width,
# height=video_height))
display(Video(video_to_display, width=video_width,
height=video_height))

else:
print(
Expand Down

0 comments on commit 7c7cfc5

Please sign in to comment.