##// END OF EJS Templates
Reword a WN entry
Blazej Michalik -
Show More
@@ -1,39 +1,38 b''
1 ``YouTubeVideo`` autoplay and the ability to add extra attributes to ``IFrame``
1 ``YouTubeVideo`` autoplay and the ability to add extra attributes to ``IFrame``
2 ===============================================================================
2 ===============================================================================
3
3
4 You can add any extra attributes to the ``<iframe>`` tag using the new
4 You can add any extra attributes to the ``<iframe>`` tag using the new
5 ``extras`` argument in the ``IFrame`` class. For example::
5 ``extras`` argument in the ``IFrame`` class. For example::
6
6
7 In [1]: from IPython.display import IFrame
7 In [1]: from IPython.display import IFrame
8
8
9 In [2]: IFrame(src="src", width=300, height=300, extras=['loading="eager"'])
9 In [2]: IFrame(src="src", width=300, height=300, extras=['loading="eager"'])
10
10
11 The above cells will result in the following HTML code being displayed in a
11 The above cells will result in the following HTML code being displayed in a
12 notebook::
12 notebook::
13
13
14 <iframe
14 <iframe
15 width="300"
15 width="300"
16 height="300"
16 height="300"
17 src="src"
17 src="src"
18 frameborder="0"
18 frameborder="0"
19 allowfullscreen
19 allowfullscreen
20 loading="eager"
20 loading="eager"
21 ></iframe>
21 ></iframe>
22
22
23 Related to the above, the ``YouTubeVideo`` class now takes an
23 Related to the above, the ``YouTubeVideo`` class now takes an
24 ``allow_autoplay`` flag, which sets up the iframe of the embedded YouTube video
24 ``allow_autoplay`` flag, which sets up the iframe of the embedded YouTube video
25 such that it allows autoplay.
25 such that it allows autoplay.
26
26
27 .. note::
27 .. note::
28 Whether this works depends on whether the autoplay policy of the browser
28 Whether this works depends on the autoplay policy of the browser rendering
29 rendering the HTML allows it. It might not work in every circumstance, and
29 the HTML allowing it. It also could get blocked by some browser extensions.
30 could get blocked by browser extensions.
31
30
32 Try it out!
31 Try it out!
33 ::
32 ::
34
33
35 In [1]: from IPython.display import YouTubeVideo
34 In [1]: from IPython.display import YouTubeVideo
36
35
37 In [2]: YouTubeVideo("dQw4w9WgXcQ", allow_autoplay=True)
36 In [2]: YouTubeVideo("dQw4w9WgXcQ", allow_autoplay=True)
38
37
39 πŸ™ƒ
38 πŸ™ƒ
General Comments 0
You need to be logged in to leave comments. Login now