CCSimpleAudioEngine does not work?

Hey,
I am trying to get my game to play some sounds using the CCSimpleAudioEngine.SharedEngine. Sound effects in both my own game and in the GoneBananas sample application do not play anything. From the GoneBananas app:

CCSimpleAudioEngine.SharedEngine.PlayEffect("Sounds/tap");

Using the CCEffectPlayer do not work either.

I can get the background music to play if I run:

CCSimpleAudioEngine.SharedEngine.PlayBackgroundMusic ("Sounds/backgroundMusic", true);

This will only work if the code is ran either in the constructor or the AddedToScene method. Running this in a method upon a later event will play nothing. (In Android it plays nothing. In Windows it throws ContentLoadException)

Any ideas?

Best Answers

Answers

  • RamiTabbaraRamiTabbara AUMember, Xamarin Team Xamurai

    Hi Mikael,

    Just so we can replicate the problem you're encountering could you please let me know which GoneBananas solution you were using when testing (VS, WinDX, WP8)?

  • PeterKrusagerPeterKrusager DKMember ✭✭

    I am using the GoneBananas from this locaktion.

    And I am using the NuGet packages "CocosSharp for Windows using DirectX". (CocosSharp.WindowsDX version: 1.2.1.0)
    When it ties to load and play the background music it throws 'Microsoft.Xna.Framework.Content.ContentLoadException'
    Here is a stacktrace:

    at CocosSharp.CCContentManager.Load[T](String assetName, Boolean weakReference) in z:\Users\rtabbara\Desktop\CocosSharpRelease\CocosSharp\src\platform\CCContentManager.cs:line 199 at CocosSharp.CCContentManager.Load[T](String assetName) in z:\Users\rtabbara\Desktop\CocosSharpRelease\CocosSharp\src\platform\CCContentManager.cs:line 151 at CocosDenshion.CCMusicPlayer.Open(String fileName, Int32 uId) in z:\Users\rtabbara\Desktop\CocosSharpRelease\CocosSharp\src\denshion\CCMusicPlayer.MonoGame.cs:line 169 at CocosDenshion.CCSimpleAudioEngine.PreloadBackgroundMusic(String filename) in z:\Users\rtabbara\Desktop\CocosSharpRelease\CocosSharp\src\denshion\CCSimpleAudioEngine.cs:line 92 at GoneBananas.GoneBananasApplicationDelegate.ApplicationDidFinishLaunching(CCApplication application, CCWindow mainWindow) in e:\t\cocos-sharp-samples-master\GoneBananas\GoneBananasShared\GoneBananasApplicationDelegate.cs:line 17 at CocosSharp.CCApplication.LoadContent() in z:\Users\rtabbara\Desktop\CocosSharpRelease\CocosSharp\src\platform\CCApplication.cs:line 730 at Microsoft.Xna.Framework.DrawableGameComponent.Initialize() in z:\Users\rtabbara\Desktop\CocosSharpRelease\CocosSharp\MonoGame\MonoGame.Framework\DrawableGameComponent.cs:line 63

    When I load the project the tap sound file is a .xnb file and the backgroundMusic file is not there. I had to copy the mp3 from the android content folder. I have set the "Build Action" to Content and the "Copy to Output Directory" to Copy always. This was not the default when the project was first loaded.

    To test the Android I use the NuGet packages "CocosSharp for Android". (CocosSharp.Android version 1.2.1.0)
    Here the background music plays beautifully but the "Sounds/tap.mp3" that should play when you hit a banana does not.

    I have not tested the WP8 nor the iOS version.

  • PeterKrusagerPeterKrusager DKMember ✭✭

    The problem seems to be fixed if you just convert everything to .xnb files. This can be done using the MonoGame Pipeline program.

    Thanks :)

Sign In or Register to comment.