Guest User

Untitled

a guest
Jan 15th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. .
  2. .
  3. .
  4. -(IBAction) playSound1
  5. {
  6. NSString *nameOfSong = @"song1";
  7. [self nowPlay:nameOfSong];
  8. }
  9.  
  10. -(IBAction) playSound2
  11. {
  12. NSString *nameOfSong = @"song2";
  13. [self nowPlay:nameOfSong];
  14. }
  15.  
  16. -(void) nowReallyPlay:(NSString*) whatsTheName
  17. {
  18. NSURL *playSong = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:whatsTheName ofType:@"mp3"]];
  19. self.soundPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:playSong error:nil];
  20. soundPlayer.delegate = self;
  21. soundPlayer.volume= 0.5;
  22. soundPlayer.numberOfLoops = 0;
  23. [soundPlayer play];
  24. }
  25. .
  26. .
  27. .
  28.  
  29. .
  30. .
  31. -(IBAction) playSound1
  32. {
  33. NSString *nameOfSong = @"song1";
  34. NSString *playThis = @"first_song";
  35. [self nowPlay:nameOfSong:playThis];
  36. }
  37.  
  38. -(IBAction) playSound2
  39. {
  40. NSString *nameOfSong = @"song2";
  41. NSString *playThis = @"second_song";
  42. [self nowPlay:nameOfSong:playThis];
  43. }
  44.  
  45. -(void) nowReallyPlay:(NSString*) whatsTheName : (NSString*) playWhat
  46. {
  47. if (playWhat == @"first_song")
  48. {
  49. NSURL *playSong = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:whatsTheName ofType:@"mp3"]];  
  50. self.soundPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:playSong error:nil];
  51. sound1Player.delegate = self;
  52. sound1Player.volume= 0.5;
  53. sound1Player.numberOfLoops = 0;
  54. [sound1Player play];
  55.  
  56. } else if (playWhat == @"second_song"") {
  57.  
  58. NSURL *playSong = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:whatsTheName ofType:@"mp3"]];  
  59. self.sound2Player = [[AVAudioPlayer alloc] initWithContentsOfURL:playSong error:nil];
  60.  
  61. sound2Player.delegate = self;
  62. sound2Player.volume= 0.5;
  63. sound2Player.numberOfLoops = 0;
  64. [sound2Player play];
  65. }
  66. }
  67. .
  68. .
Add Comment
Please, Sign In to add comment