0

Hi guys I was facing a lagging issues when using vlc packages for video playing in python. This would effect the time sleep as the duration is no longer the same when lagging occur.

youtubeURL = "https://www.youtube.com/watch?v=" + youtubeID
duration = self.get_sec(pafy.new(youtubeURL).duration)
print(duration)
try:
     stream = pafy.new(youtubeURL).streams[0]
     self.mediaPlayer = vlc.MediaPlayer(stream.url)
     self.mediaPlayer.play()
     time.sleep(duration + 3)
 
except:
     pass
Wesley
  • 65
  • 9
  • Are you using time.sleep to measure the duration of the video and do things before/after ? – Crapicus Sep 07 '22 at 15:30
  • Hi I just put on my code, yes I do measure it, just the the lagging issues is a problem – Wesley Sep 07 '22 at 15:36
  • Can you use mediaPlayer.is_playing() to detect when your media has actually started/stopped to allow for random lag? – Crapicus Sep 07 '22 at 15:52

0 Answers0