我正在尝试在播放音频文件时设置音量,但它似乎根本不起作用。请问我做错了什么?
# create a vlc playable object from source
self.playable = vlc.libvlc_media_new_path(self.instance, sourceURL)
# create a new vlc player
self.player = vlc.libvlc_media_player_new_from_media(self.playable)
# play
vlc.libvlc_media_player_play(self.player)
while not self.stop:
sleep(10) # sleep for a while to allow playback
self.player.audio_set_volume(50) # suppose to reduce volume. Doesn't work
sleep(10) # sleep for a while to allow playback
self.stop = True
答案 0 :(得分:1)
更新尝试以下内容:
self.instance = vlc.Instance()
self.mediaplayer = self.instance.media_player_new()
self.media = self.instance.media_new(unicode(sourceURL))
self.mediaplayer.set_media(self.media)
self.media.parse()
while True :
sleep(10)
self.mediaplayer.audio_set_volume(50)
请记住,volume_level是0到100之间的整数,100将等于0db。
做了一个很大的编辑,因为我觉得我最初误解了一下。视频输出是否适合您?