When trying to play a YouTube URL with VLC media player via the Python bindings, the video does not actually play.
Here is my code which does the playing:
def play(self, mrl):
self.instance = vlc.Instance()
try:
self.media = self.instance.media_new_location(mrl)
except NameError:
print('NameError: %s (%s vs LibVLC %s)' % (sys.exc_info()[1],
vlc.__version__,
vlc.libvlc_get_version()))
self.player = self.instance.media_player_new()
self.player.set_media(self.media)
event_manager = self.player.event_manager()
event_manager.event_attach(vlc.EventType.MediaPlayerEndReached, self.end_callback)
self.player.play()
while self.stillPlaying:
#do nothing
pass
And I call it like this:
play("http://www.youtube.com/watch?v=2hP-UGqA1Ek")
If you do use VLC media player to play this type of link, it will 'find' the video and play it. But all that happens with my code is a standard HTTP GET for the page, and a return of the page content from YouTube, but no video.