my radio is not working

well, tought since i want ackground music in my game, let’s make a radio:
but unforunantly, it doesn’t work

import direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject


class World(DirectObject):

    def __init__(self):
    
        self.curPlay = 0
        self.curLoopPlay = 0
        self.killm = 1
        self.killl = 1
        
        bgs = []
        plm = []
        bgs[0] = loader.loadSfx("audio/bg1.mp3")
        bgs[1] = loader.loadSfx("audio/bg2.mp3")
        bgs[2] = loader.loadSfx("audio/bg3.mp3")
        plm[0] = plm[1] = loader.loadSfx("audio/loop1.mp3")
        
        
        def bgm(self, task):
          total = bgs[1].status() + bgs[2].status() + bgs[3].status()
          if total == 3:
            self.curPlay = self.curPlay + 1
            if self.curPlay > 2:
              self.curPlay = 0
            bgs[self.curPlay].play()
          return task.cont
      
        def dbgm(self):
          if self.killm == 1:
            taskMgr.remove(bgm)
            self.killm = 2
          elif self.killm == 2:
            taskMgr.add(bmg, "bgm",extraArgs=[self],appendTask=True)
          else:
            self.killm == 1
      
        def plm(self, task):
          totall = plm[1].status() + plm[2].status()
          if totall == 2:
            self.curLoopPlay + 1
            if self.curLoopPlay > 1:
              self.curLoopPlay = 0
            plm[self.curLoopPlay].play()
          return task.cont
      
        def dplm():
          if self.killl == 1:
            taskMgr.remove(plm)
            self.killl = 2
          elif self.killl == 2:
            taskMgr.add(plm, "plm",extraArgs=[self],appendTask=True)
          else:
             self.killl == 1
        
        self.accept("p", dbgm, [self])
        self.accept("o", dplm, [self])
      
    
w=World()
run()

you cant access a list object that doesnt exist:

bgs = [] 
bgs.append( loader.loadSfx("audio/bg1.mp3") )
...

bgs[0] is the first element of the list.

thanks,
but another issue, i just downloaded some mp3 files, and i wanted to play them in panda, but they don’t give any sound.
i heard some converters put a blank part at the end, but this is the front.

if i play them with my standart music player i get good and clear sound.

assainator

To make sure it isn’t something in your code, try running something very simple, like this:

from direct.directbase import DirectStart
sfx=loader.loadSfx("audio/loop1.mp3")
sfx.play()
run()

yeah, it was my code, i haven´t found it but it´s working now and that´s good enough for me

thanks for the advice

assainator