Pergunta

When I exit from a view I start a jingle and when i return in this view I want to stop this jingle (wma)

when I exit in IbAction I have this code:

NSString *path = [NSString stringWithFormat:@"%@/%@",
                  [[NSBundle mainBundle] resourcePath],
                  @"file.wav"];

NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO];

AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID);
AudioServicesPlaySystemSound(soundID);

but when I return in the view I try to write in viewWillAppear

AudioServicesRemoveSystemSoundCompletion(soundID);
AudioServicesDisposeSystemSoundID(soundID);

but it don't work, can you help me?

Foi útil?

Solução

viewWillAppear: not will be called in some cases. You can use notification center ([NSNotificationCenter defaultCenter]) or delegate to let your view now when to stop music. There are some methods like postNotification: and addObserver:, check them.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top