You are not holding the instance open
import vlc
Instance = vlc.Instance()
player = Instance.media_player_new()
Media = Instance.media_new('2005.mp3')
Media.get_mrl()
player.set_media(Media)
player.play()
while player.get_state() !=6:
continue
Should work or
try this:
import vlc
import time
import sys
def progressbar(progress,guage_length=50):
div = 100 / float(guage_length)
prog = int(progress / div) # ensure progress fits in guage
text = "\rPlaying: {0}{1}{2} [{3}%]".format(">"*prog,"|","-"*(guage_length - prog),format(progress,'.2f'))
sys.stdout.write(text)
sys.stdout.flush()
instance = vlc.Instance()
player = instance.media_player_new()
player.set_mrl("V2.mp4")
player.play()
playing = set([1,2,3,4])
play=True
guage_length=30
while play == True:
time.sleep(0.5)
play_state = player.get_state()
if play_state in playing:
length = player.get_length()
ptime = player.get_time()
progress = ptime/float(length)*100
progressbar(progress,guage_length)
continue
else:
progressbar(100,guage_length)
play = False
print ("\nPlay terminated")
Note that # State 0: None,1 Opening,2 Buffering,3 Playing,4 Paused,5 Stopped,6 Ended,7 Error
Caveat: tested on Linux only
Instancetovlc_instanceor similar and rename in the other lines as well.