VLC 媒体列表播放器定时音频暂停
VLC Media List Player timed audio pause
在使用 Python 程序的 Raspberry Pi 上,我正在使用媒体列表播放器播放一组音频文件。但是我用来设置的具体代码是:
player = vlc.Instance('--no-xlib --quiet ') # no-xlib for linux and quiet don't complain
media_player = vlc.MediaListPlayer() # creating a media player object
media_list = player.media_list_new() # creating a new media list
media_player.set_media_list(media_list) # setting media list to the media player
new = player.media_player_new() # new media player instance
media_player.set_media_player(new) # setting media player to it
media_events = new.event_manager() # setting event handler
# setting up events
media_events.event_attach(vlc.EventType.MediaPlayerMediaChanged, vlc_SongStarted)
media_events.event_attach(vlc.EventType.MediaPlayerEndReached, vlc_SongFinished)
在 MediaPlayerEndReached 事件中,我试图在 vlc(不是实际程序)中插入暂停 - 我试图避免使用“time.sleep()”。基本上,我试图在轨道之间暂停 vlc 3 秒。我试过了:
media_player.audio_set_delay(3000)
这导致:
AttributeError: 'MediaListPlayer' object has no attribute 'audio_set_delay'
有道理,所以我尝试使用实际的媒体播放器并尝试:
media_player.get_media_player.audio_set_delay(3000)
这导致:
AttributeError: 'function' object has no attribute 'audio_set_delay'
我很难过。有没有办法在 Python 中为 vlc 定时暂停而不暂停整个 python 程序?
试试在media_player.get_media_player.audio_set_delay(3000)
中的get_media_player
加上一对圆括号,这样就变成了media_player.get_media_player().audio_set_delay(3000)
;-) !
在使用 Python 程序的 Raspberry Pi 上,我正在使用媒体列表播放器播放一组音频文件。但是我用来设置的具体代码是:
player = vlc.Instance('--no-xlib --quiet ') # no-xlib for linux and quiet don't complain
media_player = vlc.MediaListPlayer() # creating a media player object
media_list = player.media_list_new() # creating a new media list
media_player.set_media_list(media_list) # setting media list to the media player
new = player.media_player_new() # new media player instance
media_player.set_media_player(new) # setting media player to it
media_events = new.event_manager() # setting event handler
# setting up events
media_events.event_attach(vlc.EventType.MediaPlayerMediaChanged, vlc_SongStarted)
media_events.event_attach(vlc.EventType.MediaPlayerEndReached, vlc_SongFinished)
在 MediaPlayerEndReached 事件中,我试图在 vlc(不是实际程序)中插入暂停 - 我试图避免使用“time.sleep()”。基本上,我试图在轨道之间暂停 vlc 3 秒。我试过了:
media_player.audio_set_delay(3000)
这导致:
AttributeError: 'MediaListPlayer' object has no attribute 'audio_set_delay'
有道理,所以我尝试使用实际的媒体播放器并尝试:
media_player.get_media_player.audio_set_delay(3000)
这导致:
AttributeError: 'function' object has no attribute 'audio_set_delay'
我很难过。有没有办法在 Python 中为 vlc 定时暂停而不暂停整个 python 程序?
试试在media_player.get_media_player.audio_set_delay(3000)
中的get_media_player
加上一对圆括号,这样就变成了media_player.get_media_player().audio_set_delay(3000)
;-) !