I’m using this example to make a simple audio player which involves using the QTKit framework, although I can’t figure figure out how to make a ‘toggle’ play/pause button instead of two separate buttons.
I’ve tried using the following code and it doesn’t work, the error message is: (Statement requires expression of scalar type (‘void’ invalid)
- (IBAction)togglePlayback:(id)sender;
{
if([self play])
{
[self stop];
}
else
{
[self play];
}
}
Any help would be appreciated, or if there is a better way to have an audio track play when the application opens with a toggle ‘play/pause’ switch.
Well it looks like [self play] doesn’t return YES or NO. You could go for an instance variable (e.g. isPlaying) which you are toggling.
Btw – If you are targeting 10.7 lion or iOS you could go for AVFoundation/AVAudioPlayer which is a bit newer API.