StreamingKit
StreamingKit copied to clipboard
How to play Random songs and how can i enable and disable repeat
I want to find out is there any way to play random songs from a array and how do i enable and disable repeat functionality? Any help would be grateful
anybody have no idea ?
We do that thru our call backs from our custom Media Picker. We do not set it thru the StreamKit. We pass the songs to it via NSURL.
For random:
let index = Int(arc4random_uniform(UInt32(yourArray.count)))
There is no repeat functionality. You have to implement it yourself. Like the demo sample do:
-(void) audioPlayer:(STKAudioPlayer*)audioPlayer didFinishBufferingSourceWithQueueItemId:(NSObject*)queueItemId
{
[self updateControls];
// This queues on the currently playing track to be buffered and played immediately after (gapless)
if (repeatSwitch.on)
{
SampleQueueId* queueId = (SampleQueueId*)queueItemId;
NSLog(@"Requeuing: %@", [queueId.url description]);
[self->audioPlayer queueDataSource:[STKAudioPlayer dataSourceFromURL:queueId.url] withQueueItemId:[[SampleQueueId alloc] initWithUrl:queueId.url andCount:queueId.count + 1]];
}
}