L.Barreira
L.Barreira

Reputation: 51

Trying to display youtube video in jupyter notebook

I'm trying to display youtube video in jupyter notebook. But when i place the code in a condition, it doesn't show. But if i remove the if condition it works.

from IPython.display import HTML
a = input()
if a=="a":
  HTML('<iframe src="https://www.youtube.com/embed/S_f2qV2_U00?rel=0&amp;controls=0&amp;showinfo=0" width="560" height="315" frameborder="0" allowfullscreen></iframe>')
else:
  print('erro')

the code above will not show the box of the video. but if i remove the if condition like in this one,

from IPython.display import HTML
a = input()
HTML('<iframe src="https://www.youtube.com/embed/S_f2qV2_U00?    rel=0&amp;controls=0&amp;showinfo=0" width="560" height="315"  frameborder="0" allowfullscreen></iframe>')

it will work just fine.

Upvotes: 5

Views: 10303

Answers (1)

Jaya Raghavendra
Jaya Raghavendra

Reputation: 1577

Try this trick and let me know:

from IPython.display import YouTubeVideo

YouTubeVideo('WSbgixdC9g8', width=800, height=300)

Upvotes: 27

Related Questions