如果我将YouTube视频片段嵌入到iPython笔记本中:
from IPython.display import YouTubeVideo
YouTubeVideo("Pi9NpxAvYSs")
有没有办法可以嵌入这个,以便它可以在特定时间播放?所以1:47:03 - 1小时47分3秒?
如果我将YouTube视频片段嵌入到iPython笔记本中:
from IPython.display import YouTubeVideo
YouTubeVideo("Pi9NpxAvYSs")
有没有办法可以嵌入这个,以便它可以在特定时间播放?所以1:47:03 - 1小时47分3秒?
现在你可以使用了 任何参数 你喜欢youtube播放器:
from datetime import timedelta
start=int(timedelta(hours=1, minutes=46, seconds=40).total_seconds())
YouTubeVideo("Pi9NpxAvYSs", start=start, autoplay=1, theme="light", color="red")
该 目前的实施 不允许它,但它很容易扩展:
from datetime import timedelta
class YouTubeVideo(object):
def __init__(self, id, width=400, height=300, start=timedelta()):
self.id = id
self.width = width
self.height = height
self.start = start.total_seconds()
def _repr_html_(self):
return """
<iframe
width="%i"
height="%i"
src="http://www.youtube.com/embed/%s?start=%i"
frameborder="0"
allowfullscreen
></iframe>
"""%(self.width, self.height, self.id, self.start)
瞧:
YouTubeVideo("Pi9NpxAvYSs", start=timedelta(hours=1, minutes=47, seconds=3))
现在我们可以发送拉取请求:)
现在你可以使用了 任何参数 你喜欢youtube播放器:
from datetime import timedelta
start=int(timedelta(hours=1, minutes=46, seconds=40).total_seconds())
YouTubeVideo("Pi9NpxAvYSs", start=start, autoplay=1, theme="light", color="red")
该 目前的实施 不允许它,但它很容易扩展:
from datetime import timedelta
class YouTubeVideo(object):
def __init__(self, id, width=400, height=300, start=timedelta()):
self.id = id
self.width = width
self.height = height
self.start = start.total_seconds()
def _repr_html_(self):
return """
<iframe
width="%i"
height="%i"
src="http://www.youtube.com/embed/%s?start=%i"
frameborder="0"
allowfullscreen
></iframe>
"""%(self.width, self.height, self.id, self.start)
瞧:
YouTubeVideo("Pi9NpxAvYSs", start=timedelta(hours=1, minutes=47, seconds=3))
现在我们可以发送拉取请求:)