Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .
- .
- .
- -(IBAction) playSound1
- {
- NSString *nameOfSong = @"song1";
- [self nowPlay:nameOfSong];
- }
- -(IBAction) playSound2
- {
- NSString *nameOfSong = @"song2";
- [self nowPlay:nameOfSong];
- }
- -(void) nowReallyPlay:(NSString*) whatsTheName
- {
- NSURL *playSong = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:whatsTheName ofType:@"mp3"]];
- self.soundPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:playSong error:nil];
- soundPlayer.delegate = self;
- soundPlayer.volume= 0.5;
- soundPlayer.numberOfLoops = 0;
- [soundPlayer play];
- }
- .
- .
- .
- .
- .
- -(IBAction) playSound1
- {
- NSString *nameOfSong = @"song1";
- NSString *playThis = @"first_song";
- [self nowPlay:nameOfSong:playThis];
- }
- -(IBAction) playSound2
- {
- NSString *nameOfSong = @"song2";
- NSString *playThis = @"second_song";
- [self nowPlay:nameOfSong:playThis];
- }
- -(void) nowReallyPlay:(NSString*) whatsTheName : (NSString*) playWhat
- {
- if (playWhat == @"first_song")
- {
- NSURL *playSong = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:whatsTheName ofType:@"mp3"]];
- self.soundPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:playSong error:nil];
- sound1Player.delegate = self;
- sound1Player.volume= 0.5;
- sound1Player.numberOfLoops = 0;
- [sound1Player play];
- } else if (playWhat == @"second_song"") {
- NSURL *playSong = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:whatsTheName ofType:@"mp3"]];
- self.sound2Player = [[AVAudioPlayer alloc] initWithContentsOfURL:playSong error:nil];
- sound2Player.delegate = self;
- sound2Player.volume= 0.5;
- sound2Player.numberOfLoops = 0;
- [sound2Player play];
- }
- }
- .
- .
Add Comment
Please, Sign In to add comment