##// END OF EJS Templates
Merge pull request #13148 from meeseeksmachine/auto-backport-of-pr-13147-on-7.x...
Blazej Michalik -
r26791:ad591789 merge
parent child Browse files
Show More
@@ -1,13 +1,15 b''
1 Enable 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
4 You can add any extra attributes to the ``<iframe>`` tag using the new
5 since the argument ``extras`` has been added to the ``IFrame`` class.
5 ``extras`` argument in the ``IFrame`` class. For example::
6 for example::
7
6
8 In [1]: from IPython.display import IFrame
7 In [1]: from IPython.display import IFrame
9
8
10 In [2]: print(IFrame(src="src", width=300, height=300, extras=["hello", "world"])._repr_html_())
9 In [2]: IFrame(src="src", width=300, height=300, extras=['loading="eager"'])
10
11 The above cells will result in the following HTML code being displayed in a
12 notebook::
11
13
12 <iframe
14 <iframe
13 width="300"
15 width="300"
@@ -15,23 +17,22 b' for example::'
15 src="src"
17 src="src"
16 frameborder="0"
18 frameborder="0"
17 allowfullscreen
19 allowfullscreen
18 hello world
20 loading="eager"
19 ></iframe>
21 ></iframe>
20
22
21 Using it, you can autoplay ``YouTubeVideo`` by adding ``'allow="autoplay"'``,
23 Related to the above, the ``YouTubeVideo`` class now takes an
22 even in browsers that disable it by default, such as Google Chrome.
24 ``allow_autoplay`` flag, which sets up the iframe of the embedded YouTube video
23 And, you can write it more briefly by using the argument ``allow_autoplay``.
25 such that it allows autoplay.
26
27 .. note::
28 Whether this works depends on the autoplay policy of the browser rendering
29 the HTML allowing it. It also could get blocked by some browser extensions.
30
31 Try it out!
24 ::
32 ::
25
33
26 In [1]: from IPython.display import YouTubeVideo
34 In [1]: from IPython.display import YouTubeVideo
27
35
28 In [2]: print(YouTubeVideo("video-id", allow_autoplay=True)._repr_html_())
36 In [2]: YouTubeVideo("dQw4w9WgXcQ", allow_autoplay=True)
29
37
30 <iframe
38 🙃
31 width="400"
32 height="300"
33 src="https://www.youtube.com/embed/video-id?autoplay=1"
34 frameborder="0"
35 allowfullscreen
36 allow="autoplay"
37 ></iframe>
General Comments 0
You need to be logged in to leave comments. Login now