Violà! Getting CDSoundSource, and then the soundId from that works.
(The second line is optional, it just plays the sound).
CDSoundEngine *engine = [CDAudioManager sharedManager].soundEngine;
[[SimpleAudioEngine sharedEngine] playEffect:@"soundeffect.m4a"];
CDSoundSource *aSound =[[SimpleAudioEngine sharedEngine] soundSourceForFile:@"soundeffect.m4a"];
float seconds = [engine bufferDurationInSeconds:aSound.soundId];
Also to run a method right when it finishes playing I would use an NSTimer that uses the seconds result.
[NSTimer scheduledTimerWithTimeInterval:seconds target:self selector:@selector(aMethod) userInfo:nil repeats:NO];
And then the final method implements something.
-(void)aMethod
{
NSLog(@"finished playing");
}
Although, this doesn't effect the -1 result, I have to point out that the soundId variable appears twice as two different kinds in your code, in the same line, which will cause problems. No worries though, I have tested my method above with success.
ALuint **soundId** = [[SimpleAudioEngine sharedEngine] playEffect:**soundId**];