Reputation: 554
I'm using a MediaListPlayer
instance to execute a playlist. On a standard MediaPlayer
instance you can use MediaPlayer.audio_set_volume(newVolume)
, but when I try to use the same method(audio_set_volume(newVolume)
) on a MediaListPLayer
instance, I get an error.:
AtributeError: 'MediaListPLayer' object has no attribute 'audio_set_volume'
. What is the replacement of that method for the MediaListPlayer
?
This is the code:
from vlc import Instance
playlist = ['/home/user/Music/01 Signs.mp3','/home/user/Music/2U.mp3']
player = Instance()
mediaListPlayer = player.media_list_player_new()
mediaList = player.media_list_new()
for element in playlist:
mediaList.add_media(player.media_new(element))
mediaListPlayer.set_media_list(mediaList)
mediaListPlayer.play()
mediaListPlayer.audio_set_volume(80)
Upvotes: 2
Views: 1980
Reputation: 66
Two years later was wondering the same thing. So here is a solution that worked for me:
import vlc
inst = vlc.Instance()
player = inst.media_list_player_new()
media_list = inst.media_list_new(["example.mp3"])
player.set_media_list(media_list)
player.play()
player.get_media_player().audio_set_volume(50)
MediaListPlayer.get_media_player() returns the MediaPlayer that can be used to control the volume of the MediaListPlayer during playback.
Upvotes: 5
Reputation: 22443
As I said in my comment, it does look like an oversight.
However, I have managed to set the initial volume by hacking a sub_player but once it is set and you invoke the list player, I haven't found a way of adjusting it after that.
import vlc
import time
playlist=['/home/rolf/vp1.mp3','/home/rolf/vp.mp3']
inst = vlc.Instance()
sub_player = inst.media_player_new()
player = inst.media_list_player_new()
mediaList = inst.media_list_new(playlist)
player.set_media_list(mediaList)
volume = 60
sub_player.audio_set_volume(volume)
sub_player.play()
playing = set([1,2,3,4])
player.play()
while player.get_state() in playing:
time.sleep(1)
I have posted a question on videolan ,https://forum.videolan.org/viewtopic.php?f=32&t=139505 so someone with a greater knowledge of these things might provide a better solution. If I get an answer, I'll post it here.
Upvotes: 0