Playing youtube video
Posted: 09 Nov 2020 18:27
I'm programming a music player with python, tkinter and vlc. My idea is to streem a youtube video with it's URL, which I was doing with pafy. I have downloaded youtube-dcl, since the takedown of youtube-dl, but pafy doesn't work to get the best URL. So, I'm trying to do it directly with the vlc module. I have tried the following:
I have asked in StackOverflow: https://stackoverflow.com/questions/646 ... ube-videos
The only answer says that I need to parse the media and play it's first subitem, but the code doesn't work. Instead of parse() I have used parse_with_options() and instead of first() I have tried item_at_index(0), but doesn't work anyway.... I have looked for examples or information, but I can't find much. Can you help me, please? Thanks!
Code: Select all
import vlc
import time
url = "https://www.youtube.com/watch?v=s5TIulzXoXo"
instance = vlc.Instance()
media = instance.media_new(url)
player = instance.media_player_new()
player.set_media(media)
player.play()
The only answer says that I need to parse the media and play it's first subitem, but the code doesn't work. Instead of parse() I have used parse_with_options() and instead of first() I have tried item_at_index(0), but doesn't work anyway.... I have looked for examples or information, but I can't find much. Can you help me, please? Thanks!