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