我目前正在使用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()
您可以通过设置播放模式来执行此操作:
import vlc
self.Player.set_playback_mode(vlc.PlaybackMode.loop)