Guest User

Untitled

a guest
Jan 16th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. NSString *fileName = [[NSBundle mainBundle] pathForResource:@"Alarm" ofType:@"caf"];
  2. NSURL *url = [[NSURL alloc] initFileURLWithPath:fileName];
  3. NSLog(@"Test: %@ ", url);
  4.  
  5. AVAudioPlayer *audioFile = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:NULL];
  6. audioFile.delegate = self;
  7. audioFile.volume = 1;
  8.  
  9. [audioFile play];
  10.  
  11. // Build URL to the sound file we are going to play
  12. NSURL *sound_file = [[NSURL alloc] initFileURLWithPath: [[NSBundle mainBundle] pathForResource:sound_file_name ofType:@"mp3" inDirectory:directory]];
  13.  
  14. // Play it
  15. audio_player = [[AVAudioPlayer alloc] initWithContentsOfURL:sound_file error:nil];
  16. audio_player.delegate = self;
  17. [audio_player play];
  18. [sound_file release];
Add Comment
Please, Sign In to add comment