Show More
@@ -0,0 +1,35 b'' | |||
|
1 | """Various display related classes. | |
|
2 | ||
|
3 | Authors : MinRK | |
|
4 | """ | |
|
5 | ||
|
6 | class YouTubeVideo(object): | |
|
7 | """Class for embedding a YouTube Video in an IPython session, based on its video id. | |
|
8 | ||
|
9 | e.g. to embed the video on this page: | |
|
10 | ||
|
11 | http://www.youtube.com/watch?v=foo | |
|
12 | ||
|
13 | you would do: | |
|
14 | ||
|
15 | vid = YouTubeVideo("foo") | |
|
16 | display(vid) | |
|
17 | """ | |
|
18 | ||
|
19 | def __init__(self, id, width=400, height=300): | |
|
20 | self.id = id | |
|
21 | self.width = width | |
|
22 | self.height = height | |
|
23 | ||
|
24 | def _repr_html_(self): | |
|
25 | """return YouTube embed iframe for this video id""" | |
|
26 | return """ | |
|
27 | <iframe | |
|
28 | width="%i" | |
|
29 | height="%i" | |
|
30 | src="http://www.youtube.com/embed/%s" | |
|
31 | frameborder="0" | |
|
32 | allowfullscreen | |
|
33 | ></iframe> | |
|
34 | """%(self.width, self.height, self.id) | |
|
35 |
General Comments 0
You need to be logged in to leave comments.
Login now