I'm building an SongApp with random Sounds playing out of my Playlist.
I have now an NSMutableArray which contains Songs. For Example:
NSMutableArray *array=[NSMutableArray
arrayWithObjects:
@"Song1.mp3",
@"Song2.mp3",
@"Song3.mp3",
@"Song4.mp3",
@"Song5.mp3",
@"Song6.mp3",
@"Song7.mp3",
@"Song8.mp3",
@"Song9.mp3",
nil];
int i=0;
for(i=0;i<=[array count]; i++)
{
NSInteger rand=(arc4random() %9);
[array exchangeObjectAtIndex:i
withObjectAtIndex:rand];
}
I declared it as Instance Method.
Now i have many Buttons in different Colors. And each Button should play a Song. But everytime i call the new View, the Button should play an other Song.
I hope you understand me :)
My problem is:
Is there any way, that when i want, that the yellow button for example plays "Song1" overtime in this View, but when i load the View another time it plays "Song5" for example?
How can i say each Button to play out of my Array? I only know the
NSString *play = [[NSBundle mainBundle] pathForResource:@"Song1" ofType:@"mp3"]; NSURL *playURL = [NSURL fileURLWithPath:pewPewPath]; AudioServicesCreateSystemSoundID((__bridge CFURLRef)playURL, & self.song1); AudioServicesPlaySystemSound(self.song1);
Hope you understand my questions :)
Thanks & best regards!