This documentation covers IPython versions 6.0 and higher. Beginning with version 6.0, IPython stopped supporting compatibility with Python versions lower than 3.3 including all versions of Python 2.7.

If you are looking for an IPython version compatible with Python 2.7, please use the IPython 5.x LTS release and refer to its documentation (LTS is the long term support release).

YouTubeVideo autoplay and the ability to add extra attributes to IFrame

You can add any extra attributes to the <iframe> tag using the new extras argument in the IFrame class. For example:

In [1]: from IPython.display import IFrame

In [2]: IFrame(src="src", width=300, height=300, extras=['loading="eager"'])

The above cells will result in the following HTML code being displayed in a notebook:


Related to the above, the YouTubeVideo class now takes an allow_autoplay flag, which sets up the iframe of the embedded YouTube video such that it allows autoplay.


Whether this works depends on the autoplay policy of the browser rendering the HTML allowing it. It also could get blocked by some browser extensions.

Try it out!

In [1]: from IPython.display import YouTubeVideo

In [2]: YouTubeVideo("dQw4w9WgXcQ", allow_autoplay=True)