Demo entry 2513076

Playlist

   

Submitted by anonymous on Aug 26, 2015 at 00:26
Language: Objective-J. Code size: 743 Bytes.

- (void)selectSound:(UIButton *)sender {

    // Same track touched -> Stop
    if ([_audioPlayer isPlaying] && (sender.tag == currentlyPlaying)) {
        [_audioPlayer setVolume:0];
        [NSThread sleepForTimeInterval:.05];
        [_audioPlayer stop];

    // Different track touched -> Play
    } else {
        if ([_audioPlayer isPlaying]) {
            [_audioPlayer setVolume:0];
            [NSThread sleepForTimeInterval:.05];
            [_audioPlayer stop];
        }

        NSArray *soundForCell = [soundCollection objectAtIndex:sender.tag];
        [self playSound:(soundForCell[0]) volume:1.0 numberOfLoops:0];
        currentlyPlaying = sender.tag;

        NSLog(@"%zd", currentlyPlaying);
    }

}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).