The switch statement needs an integer. The integer you want in this case is the index of the current AVPlayerItem being played.
So, keep a copy of the array you passed an array of AVPlayerItems to the AVQueuePlayer. Then find the current player item in this array, and you'll have your index value.
NSInteger index = [self.soundEmotions indexOfObject:self.player.currentItem];
NSString *imageName = nil;
switch (index) {
case 0:
imageName = @"yellow"; // You don't need the ".png" part.
break:
case 1:
imageName = @"orange";
break:
case 2:
imageName = @"red";
break:
case 3:
imageName = @"pink";
break:
default:
// Any other number or NSNotFound.
break:
}
if (imageName) {
[UIView transitionWithView:self.view
duration:1.0f
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
mainImage.image = [UIImage imageNamed:imageName];
}
completion:NULL];
}
Also, you can use an enum for constants for better readability. These are just sequential integers.
typedef enum {
MyClassPlayerVoiceYellow = 0,
MyClassPlayerVoiceOrange,
MyClassPlayerVoiceRed,
MyClassPlayerVoicePink,
} MyClassPlayerVoice;
Then use them in the switch:
switch (index) {
case MyClassPlayerVoiceYellow:
imageName = @"yellow"; // You don't need the ".png" part.
break:
case MyClassPlayerVoiceOrange:
imageName = @"orange";
break:
case MyClassPlayerVoiceRed:
imageName = @"red";
break:
case MyClassPlayerVoicePink:
imageName = @"pink";
break:
default:
break:
}