I'm trying to play a random youtube video using pafy and vlc. But when I'm executing the script :
import vlc
import cv2
url = "Youtube_URL"
video = pafy.new(url)
best = video.getbest()
playurl = best.url
ins = vlc.Instance()
player = ins.media_player_new()
Media = ins.media_new(playurl)
Media.get_mrl()
player.set_media(Media)
player.play()
I'm getting below error :
AttributeError: 'module' object has no attribute 'Instance'
I've tried a lot but vlc.Instance() is not working, I don't know why. I will appreciate any help/inputs.
don't know if you have solved the problem already. I don't really know why this happens. I only figured out that it happens when you execute pip3 install python-vlc(or something like that).
I think they might have changed some methods and objects in more recent versions.However this works for me. Here is the oficial link where I downloaded it from:
https://pypi.org/project/python-vlc/1.1.2/#files
Get the tar.gz file, extract the content and change directory, then run: sudo python3 install setup.py
You have to uninstall first the module that you installed previously: python3 uninstall vlc and python3 uninstall python-vlc. Install the one that you downloaded and then it might ask you to install again module vlc(not python-vlc). Hope this helps!