Alon Lavi
Alon Lavi

Reputation: 329

Qt or PyQt4 - How can i pull out and embed Only the box of YouTube clip?

I'm trying to create a window with QWebView as its central widget and set inside it only the youtube clip box without the rest of the information on that youtube webpage.

The YouTube links can change by request of the user.

I found this example where it works that way.

only the link address has a different form: http://www.youtube.com/v/nKIu9yen5nc instead of the usual form: http://www.youtube.com/watch?v=nKIu9yen5nc

But not all links in youtube are capable shown that way.

Upvotes: 2

Views: 928

Answers (1)

Alon Lavi
Alon Lavi

Reputation: 329

Ok. I have found a simple solution. So i write in case someone would be helped by it.(even i'm a noob to python and pyqt)

I used the code of the Embed option in youtube site itself and added html tags to make it a complete code for a web page. Then i used QWebView.setHtmel() to set that code as the page to be rendered on the QWebView. And it works :-).

view = QWebView()
s =QString("""<!DOCTYPE html>
                         <html>
                         <body>
                         <iframe width="560" height="315" src="//www.youtube.com/embed/1VQ_3sBZEm0" frameborder="0" allowfullscreen></iframe>
                         </body>
                         </html>""")

view.setHtml(s,QUrl('https://youtube.com'))

Upvotes: 3

Related Questions