I'm trying to create a simple music video player that creates an updated playlist from any MP4 files that are dropped into a specific folder (in this case a folder named 'Media')
The player then plays the videos that are listed on the playlist in a continuous loop.
I'm using a Windows 7 PC and Python 3.7
I've attached a working sample of my code, it does all of the above requirements, BUT it's not exactly seamless when switching to the next video.
I don't think I'm changing to the next video in the most efficient way. Is there a player.next_track() method or something equivalent?
Is it even possible to have a 'transition' between each video, something like a cross-fade?
Any help would be much appreciated
cheers - Jason
Code: Select all
import vlc
import time
import glob
def createPlaylist():
folder = ("./Media")
playlist = glob.glob(folder+"/*.mp4")
if len(playlist) == 0:
print("No recognisable MP4 files in ", folder)
return playlist
Instance = vlc.Instance('--input-repeat=999999', '--no-video-title-show', '--mouse-hide-timeout=5000')
a = 0
playlist = createPlaylist()
while True:
if a == len(playlist):
a = 0
playlist = createPlaylist()
print("Media folder contains ", len(playlist), "MP4 files\n")
player = Instance.media_player_new()
player.set_fullscreen(True)
MusicVideo = Instance.media_new(playlist[a])
player.set_media(MusicVideo)
player.play()
#get duration of movie file
time.sleep(1.5)
duration = player.get_length()/1000
dwell = duration -1.5
time.sleep(dwell)
player.stop()
a += 1