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 783cc9c commit 29947bf
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 27 deletions.
14 changes: 0 additions & 14 deletions musicalgestures/.readthedocs.yml

This file was deleted.

29 changes: 24 additions & 5 deletions musicalgestures/_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
from matplotlib import pyplot as plt
from IPython.display import Image, display
# try:
from IPython.display import Video
# from IPython.display import Video
from IPython.display import HTML
from base64 import b64encode
# except:
# from IPython.core.display import Video
# from base64 import b64encode
Expand Down Expand Up @@ -89,13 +91,30 @@ 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('\\', '/')
display(Video(video_to_display,
width=video_width, height=video_height))

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))
else:
video_to_display = os.path.relpath(
video_to_display, os.getcwd()).replace('\\', '/')
display(Video(video_to_display, width=video_width,
height=video_height))

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))

else:
print(
Expand Down
8 changes: 0 additions & 8 deletions musicalgestures/mkdocs.yml

This file was deleted.

0 comments on commit 29947bf

Please sign in to comment.