This project is read-only.

Could not play sound

Topics: Windows Phone 8
Feb 12, 2014 at 10:21 AM
Edited Feb 12, 2014 at 10:49 AM
I've made a game using cocos2d xna WP8. I want to add some sounds for my game. But it seems does not work :(

I have a WAV sound file named tingting.xnb (from tingting.wav). Place xnb file into Content\Sound\tingting.xnb, set Build Action = Content, copy to output directory = Copy if newer
public override void ApplicationWillEnterForeground()

            // if you use SimpleAudioEngine, your background music track must resume here. 
            //CCSimpleAudioEngine.SharedEngine.PauseBackgroundMusic = false;
            CCSimpleAudioEngine.SharedEngine.PreloadBackgroundMusic("Sounds\\tingting"); (DEBUG)

I marked a debug point at DEBUG line, and has a Null Reference Exception occurred maybe file path not found. :( at
m_music = CCContentManager.SharedContentManager.Load<Song>(pFileName);

I am trying many paths for sound file such as: Sounds\tingting.xnb, Content\Sounds\tingting, Content\Sounds\tingting.xnb... but it does not work!

Please expand how to play a sound file in detail :| Thanks so much!
Feb 12, 2014 at 4:37 PM
you need to use the wav file, not the xnb file. Include both in your project and it should work.
Feb 13, 2014 at 2:29 AM

Please review WindowsPhone 8 source code, I tested testWinphone8 project, but sound play does not work!
Feb 13, 2014 at 3:03 AM
The cocosDenshion tests are not maintained so I am not surprised that the wp8 test does not play sound.
Feb 13, 2014 at 3:32 AM
When I run the denshion test in wp8 and try the effect test, I get:

A first chance exception of type 'SharpDX.SharpDXException' occurred in SharpDX.DLL
Unexpected exception while playing a SoundEffect: Sounds/effect1
SharpDX.SharpDXException: HRESULT: [0x88960001], Module: [SharpDX.XAudio2], ApiCode: [XAUDIO2_E_INVALID_CALL/InvalidCall], Message: Unknown
at SharpDX.Result.CheckError()
at SharpDX.XAudio2.SourceVoice.SubmitSourceBuffer(AudioBuffer bufferRef, IntPtr bufferWMARef)

This is the result of the xnb file and not the wav file.
Feb 19, 2014 at 4:53 AM
Edited Feb 19, 2014 at 4:55 AM
I tested the Denshion in wp8, the Background music player worked fine with (wma and xnb files). But the Sound Effect player did not work correctly with xnb file that converted from wma or wav, (same error above). How to play effect?
Feb 19, 2014 at 4:25 PM
On WP8 I only use the raw wav files. I don't use any xnb encoding for sound effects.
Feb 21, 2014 at 3:34 AM
Thanks, it worked fine!
Mar 2, 2014 at 4:57 AM
Edited Mar 2, 2014 at 5:01 AM
What build action, content importer and processor are you using for raw wav files?
I have an issue, some effects works well using compile, mp3 audio file and sound effect, but others not. So maybe the solution you are using can help me with this issue.

The console shows:
Unexpected exception while playing a SoundEffect: audio/menu/transition
System.ObjectDisposedException: This object has already been disposed.
Arguments: SoundEffect
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See
   at Microsoft.Xna.Framework.Audio.SoundEffect.Play(Single volume, Single pitch, Single pan)
   at Microsoft.Xna.Framework.Audio.SoundEffect.Play()
   at CocosDenshion.CCEffectPlayer.Play(Boolean bLoop)
   at CocosDenshion.CCSimpleAudioEngine.PlayEffect(String pszFilePath, Boolean bLoop)
Mar 2, 2014 at 5:38 AM
Sorry, the issue was related to CCContentManager unload, i added a clean to the CCSimpleAudioEngine SharedList and all is working right now.
Mar 3, 2014 at 11:52 PM
Did you post a PR back to us? That would help anyone else who might have this problem.