Play music? - Objective C

How would you play any type of music in objective-c (not iphone sdk) and how would you stop the music?

Thanks, Kevin

+2


source to share


5 answers


Here is some sample code showing how to play a sound file on Mac OS X (10.5+). It uses the AudioQueue API.
Take a look at the code for aqplay.



+2


source


Check out Getting Started with Audio and Video - iPhone Dev Center



+3


source


Since you tagged the question xcode

, take a look at NSSound and Apple Audio Review .

+1


source


-(void) playAlarmSound
{
    // Get the filename of the sound file
    NSString *path = [NSString stringWithFormat:@"%@%@",
                      [[NSBundle mainBundle] resourcePath],
                      @"/alarm.wav"];

    // Declare a sound id
    SystemSoundID soundID;

    // get a URL for the sound file
    NSURL *filepath = [NSURL fileURLWithPath:path isDirectory:NO];

    // Use audio services to create sound
    AudioServicesCreateSystemSoundID((CFURLRef) filepath, &soundID);

    // Use audio services to play the sound
    AudioServicesPlaySystemSound(soundID);
}

      

+1


source


Assuming you want to play recorded music, try using QTMovieView. There's a tutorial on how to use it here .

0


source







All Articles