0
import time
import vlc

p = vlc.MediaPlayer("Music/peachy-in2kymoW2EY.mp3")
p.play()

time.sleep(1) #wait for player to start

while p.is_playing():
        print(p.get_length()-p.get_time())

This prints out how many milliseconds are left of the audio file. But when the song ends, the last print is 101 while it should be exactly 0. This number varies a bit everytime and with different files. This can be fixed by using while True: but it gives out an error when the file has finished playing.

How can I get a more accurate result?

4

0 回答 0