StreamingKit icon indicating copy to clipboard operation
StreamingKit copied to clipboard

How to play Random songs and how can i enable and disable repeat

Open rahulbbit opened this issue 8 years ago • 3 comments

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

rahulbbit avatar Mar 12 '16 19:03 rahulbbit

anybody have no idea ?

hoootan avatar May 26 '17 18:05 hoootan

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.

doriansgithub avatar May 26 '17 18:05 doriansgithub

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]];
    }
}

iDevelopper avatar May 27 '17 12:05 iDevelopper