Hello,

I'm trying to play some music with cocos2d. I'm a bit lost as why my music 
is not played. Here is a minimal code using pyglet which works:

#!/usr/bin/python3
#-*- encoding: utf-8 -*-

import pyglet

pyglet.resource.path = ['assets']
pyglet.resource.reindex()

music = pyglet.resource.media('ThemeEcranTitre2.mp3')
music.play()

pyglet.app.run()

And here is my attempt in cocos2d which does not work (the windows open 
correctly but no music is played):

import cocos
from cocos.director import director

director.init()
intro = cocos.scene.Scene()
import pdb; pdb.set_trace()
intro.load_music("assets/ThemeEcranTitre2.mp3")

director.run(intro)

Trying to trace the problem, I found that when the scene enters, cocos is 
calling cocos.audio.music.control.load(self.music)which actually calls the 
DummyMusicControl implementation in cocos\audio\music.py.

I want to use AVBin and it's installed on my machine. What am I doing wrong?

I tried to use pygame instead, passing audio_backend='sdl' to 
director.init(). But this gives this exception:

Traceback (most recent call last):
  File "audio_test.py", line 21, in <module>
    director.run(intro)
  File "C:\Python34\lib\site-packages\cocos\director.py", line 402, in run
    self._set_scene(scene)
  File "C:\Python34\lib\site-packages\cocos\director.py", line 525, in 
_set_scene
    scene.on_enter()
  File "C:\Python34\lib\site-packages\cocos\scene.py", line 114, in on_enter
    cocos.audio.music.control.load(self.music)
  File "C:\Python34\lib\site-packages\cocos\audio\music.py", line 49, in 
load
    pygame.music.load(filename)
NameError: name 'pygame' is not defined

Daniel.

-- 
You received this message because you are subscribed to the Google Groups 
"cocos2d discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cocos-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply via email to