2

我试图在播放音频文件时设置音量,但它似乎根本不起作用。请问我做错了什么?

# 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
4

1 回答 1

2

更新尝试以下操作:

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。

做了一个大的编辑,因为我认为我最初误解了一点。视频输出是否适合您?

于 2013-09-03T19:32:21.393 回答