如何使用libVLC使VLC重复整个播放列表而不是仅重复当前项目?

时间:2017-07-10 18:56:28

标签: python vlc libvlc

我目前正在使用Python VLC绑定(libVLC)。初始化实例时,我使用--input-repeat=-1选项,但这会导致播放列表仅在我使用MediaListPlayer.next()方法时前进。我希望整个播放列表循环播放(不重复每首歌曲),而不仅仅是一首歌曲。任何有关此参数的文档也是受欢迎的(我查看了官方的libVLC文档,但找不到任何内容。

这是我现在的代码:

from vlc import Instance

playlist = ['/home/username/Music/01 Signs.mp3',
 '/home/username/Music/2U.mp3',
 '/home/username/Music/now_or_never.mp3',
 '/home/username/Music/passionfruit.mp3',
 '/home/username/Music/still_got_time.mp3']

class testVLC:

    def __init__(self):
         self.list1 = playlist
         self.Player = Instance('--loop')

    def addPlaylist(self):
        self.mediaList = self.Player.media_list_new()
        for music in self.list1:
            self.mediaList.add_media(self.Player.media_new(music))
        self.listPlayer = self.Player.media_list_player_new()
        self.listPlayer.set_media_list(self.mediaList)
    def playPlaylist(self):
        self.listPlayer.play()
    def nextPlay(self):
        self.listPlayer.next()

1 个答案:

答案 0 :(得分:3)

您可以通过设置播放模式来执行此操作:

import vlc
self.Player.set_playback_mode(vlc.PlaybackMode.loop)