Python / Shell播放随机视频

时间:2019-12-02 16:51:22

标签: python shell

我有一个树莓派,我的公司想用它来播放随机视频,然后播放文件,然后播放随机视频并重复播放。我环顾四周,没有找到完全符合这种情况的东西。我有三个不同的文件,一个完全随机,可以工作,但不符合规格。已经研究过vlc和omxplayer,但倾向于vlc。

下面是我所拥有的,并且正在寻找可以使它变得更好的指针以及任何其他反馈。

import vlc
import random
import os

path = "/home/pi/share"
seed = random.randint(0, 100) #This is where I get lost in trying to find a random video.
playlist = []
count = 0
transitionfile = "/home/pi/_Transition.mp4"

for filenames in os.walk(path):
    playlist.append(filenames) #add the filenames 

for movie in playlist:
    player = vlc.MediaPlayer(movie)
    count += 1
    if count % 2 != 0:
        player.play(transitionfile)
    player.play()

    if(player == player.stop()):
        for movie in playlist:
            player = vlc.MediaPlayer(movie)

0 个答案:

没有答案