Skip to content

Instantly share code, notes, and snippets.

@centwave
Created July 6, 2013 13:53

Revisions

  1. centwave revised this gist Jul 6, 2013. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion playsound
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,9 @@
    @implementation MyClass
    - (void) viewDidLoad {
    [super viewDidLoad];
    AudioServicesCreateSystemSoundID(.... URL ...., &mySound);

    NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"changeTrack" ofType:@"aif"];
    AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath: soundPath], &mySound);
    }

    - (void) playMySoundLikeRightNowReally {
  2. centwave created this gist Jul 6, 2013.
    19 changes: 19 additions & 0 deletions playsound
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    @interface MyClass:NSObject
    {
    SystemSoundID mySound;
    }
    @implementation MyClass
    - (void) viewDidLoad {
    [super viewDidLoad];
    AudioServicesCreateSystemSoundID(.... URL ...., &mySound);
    }

    - (void) playMySoundLikeRightNowReally {
    AudioServicesPlaySystemSound(mySound);
    }

    - (void) dealloc {
    AudioServicesDisposeSystemSoundID(mySound);
    [super dealloc];
    }
    @end