Forum Libraries, Components, and Plugins


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Issues with CCSimpleAudioEngine using CocosSharp.PCL.Shared v1.5.0.1 on iOS 8.x

I searched the forums and github issues but couldn't see anyone else running into these issue.
I had two issues with sound on iOS, the first one with a workaround in an odd way...
(new to CocosSharp so I apologize if my nomenclature is a little off..)

I have a project setup for both iOS and Android to use a shared common project using CocosSharp.PCL.Shared v1.5.0.1

Issue 1 (workaround in place):
Within a CCLayer's AddedToScene I am setting up some background music using an mp3 file with
CCSimpleAudioEngine.SharedEngine.PlayBackgroundMusic ("sounds/Music/GameTrack1", true);

This worked out of the box when running on Android. On iOS, the background music wasn't playing at all but there were no errors about missing the file.
Then on a whim I decided to just add right after the above line:
CCSimpleAudioEngine.SharedEngine.BackgroundMusicVolume = 1.0f;

And now this plays fine on iOS too. These are the first calls to any use of CCSimpleAudioEngine in the app. Is this a known issue that you have to explicitly tickle the volume setting on iOS but not Android?

Issue 2
I am trying to play an effect every time the user touches the screen with a simple call like:
CCSimpleAudioEngine.SharedEngine.PlayEffect ("sounds/Effects/Bumper1");
The effect is about 2 seconds long, and if I tap quickly in succession on Android I will hear multiple repeated immediate effects played fine on every touch.
On iOS the effect has to play to completion before a new version of the effect is heard. Is this a known limitation of the implementation on iOS or am I required to interrupt or setup explicit multiple channel support if I wanted to hear multiple effects at the same time?



  • HeikofantHeikofant USUniversity ✭✭

    Just wanted to add that I had the same issue with CCSimpleAudioEngine.SharedEngine.PlayBackgroundMusic on iOS.
    I tried .mp3, .aif., and .caf.
    I will try out tomorrow with the CCSimpleAudioEngine.SharedEngine.BackgroundMusicVolume = 1.0f; fix and will report if then my background music starts playing.

  • PeterKrusagerPeterKrusager DKMember ✭✭

    Your issue 2 is a know issue. You can follow the progress here.

    As a workaround you can either stop the effect and play it again or load multiple instances of the same effect. Neither of these are really pretty though.
    A better approach might be to implement a sound engine natively that can support multiple sound effects and use that instead when you run on iOS. I am no specialist in iOS so I have no idea of the magnitude of this task.

  • JeffAdamsJeffAdams USMember

    Thanks Peter, for the issue link, although the way it is worded makes it sound like it is impossible to play any effects at the same time, or is it only related to a single effect resource file?

    Re: 'load multiple instances of the same effect' would that require literally having multiple of the same file as duplicated unique filenames as I don't see how that can be done with the current CCSimpleAudioEngine.

    I'm a bit surprised to see this sort of limitation on iOS. I had written apps a few years back in Cocos2D-iPhone Objective-C using CocosDenshion and didn't run into this issue. Seems to make effect audio on iOS pretty limited if it has been like this for some time, I'd hate to have to break out into an iOS specific solution, but if I must...

  • kjpou1kjpou1 LUMember, Xamarin Team Xamurai

    We have setup specific iOS issues for each of your points Issue 1 and Issue 2

  • kjpou1kjpou1 LUMember, Xamarin Team Xamurai

    Hey Jeff.

    On second thought is there any way for you to create a very small and simple cross platform example for us for issue 2 with your sound effect. I was wondering if there may be a difference in the project setup and/or the effect file itself. Am not saying it is at all and just want to test with one that fails for sure.

  • JeffAdamsJeffAdams USMember
    edited July 2015

    Here is a minimal sample project built from the default solution template for Android/iOS Shared PCL CocosSharp.
    (i linked the project in the github issue as well)

    All it does is add a touch listener to the default blank CCLayer. Tap as fast as possible on Android and you will hear the bumper sound effect every tap. On iOS the current effect has to finish before another will ever play.

  • kjpou1kjpou1 LUMember, Xamarin Team Xamurai


    This should have been cleaned up this weekend and is in our source base now.

    Issue 273
    Issue 272
    Issue 157

    There is also a new AudioSample in the samples as well so one can play around with CocosDenshion. Unfortunately since we added some new functionality with the Commit it will only work with the next release. So to test this you will need to compile from source for now.

  • JeffAdamsJeffAdams USMember

    Great! thanks, yea I saw the commits and I even tried preparing to compile from source, but I'm on OS X and I am facing this issue to get nant working on OS X:
    Anyone else on OS X Yosemite have a working solution for getting CocosSharp compiled from the latest sources?

Sign In or Register to comment.