Hi Leute ich habe folgendes Problem bei Pygame.mixer
if trenn in message:
a,sounds,voll,volr= message.split(":")
sounds = (pfad + sounds)
voll=float(voll)
volr=float(volr)
if a=='start':
modus = "1"
elif a=="startl":
modus ="2"
if (player=="0" and modus =="1"):
sound1 = pygame.mixer.Sound(sounds)
chan1 = pygame.mixer.find_channel()
print(chan1)
print(voll)
print(volr)
volume=voll , volr
print(volume)
chan1.set_volume(volume)
chan1.play (sound1)
if (player=="0" and modus =="2"):
sound1 = pygame.mixer.Sound(sounds)
chan1 = pygame.mixer.find_channel()
chan1.set_volume(volume)
print(chan1)
chan1.play (sound1,loops = -1)
if (message=="stop" and player=="0"):
pygame.mixer.stop()
Alles anzeigen
Der Code ist noch nicht ganz sauber weil ich immer erst grob den Plan umsetze und dann die Programmierung verfeiner, habe aber folgendes problem. momentan mache ich folgendes ich gebe ihm ein MQTT z.b. start:trackfile:voll:volr
was ich machen will ist volume für links und volume für Rechts via mqtt definieren, ich kann set_volume(0.6,0.0) z.b. so setzen das jetzt nur Links was rauskommt. so will ich z.b. die Küche muten ... mein problem ist aber das er von mir bei chat1.set_volume(volume) ein float verlangt und mein wert in volume ist in klammern gesetzt. bin in programmieren würde sagen ok aber nicht so der obercrack vielleicht könnt ihr mir abhilfe schaffen
ZitatFile "sound.py", line 84, in on_message
chan1.set_volume(volume)
TypeError: a float is required