0

我有以下代码用于使用 python 在 VLC 中播放 mp4 文件:

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("D:\\Deep.mp4")
player.audio_set_volume(40)
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

我想做的是能够在开始演奏之前移动到特定时间。这有可能在 python-vlc 中做到这一点???

4

0 回答 0