Commit b190c991 authored by Gleb Pinigin's avatar Gleb Pinigin

Add checkmark to indicate current subtitle track in action sheet

parent f7429b90
...@@ -639,12 +639,19 @@ ...@@ -639,12 +639,19 @@
- (IBAction)switchSubtitleTrack:(id)sender - (IBAction)switchSubtitleTrack:(id)sender
{ {
NSArray *spuTracks = [_mediaPlayer videoSubTitlesNames]; NSArray *spuTracks = [_mediaPlayer videoSubTitlesNames];
NSArray *spuTrackIndexes = [_mediaPlayer videoSubTitlesIndexes];
NSUInteger count = [spuTracks count]; NSUInteger count = [spuTracks count];
if (count <= 1) if (count <= 1)
return; return;
_subtitleActionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"CHOOSE_SUBTITLE_TRACK", @"subtitle track selector") delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles: nil]; _subtitleActionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"CHOOSE_SUBTITLE_TRACK", @"subtitle track selector") delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles: nil];
for (NSUInteger i = 0; i < count; i++)
[_subtitleActionSheet addButtonWithTitle:spuTracks[i]]; for (NSUInteger i = 0; i < count; i++) {
NSString *indexIndicator = ([spuTrackIndexes[i] intValue] == [_mediaPlayer currentVideoSubTitleIndex])? @"\u2713": @"";
NSString *buttonTitle = [NSString stringWithFormat:@"%@ %@", indexIndicator, spuTracks[i]];
[_subtitleActionSheet addButtonWithTitle:buttonTitle];
}
[_subtitleActionSheet addButtonWithTitle:NSLocalizedString(@"BUTTON_CANCEL", @"cancel button")]; [_subtitleActionSheet addButtonWithTitle:NSLocalizedString(@"BUTTON_CANCEL", @"cancel button")];
[_subtitleActionSheet setCancelButtonIndex:[_subtitleActionSheet numberOfButtons] - 1]; [_subtitleActionSheet setCancelButtonIndex:[_subtitleActionSheet numberOfButtons] - 1];
[_subtitleActionSheet showInView: self.subtitleSwitcherButton]; [_subtitleActionSheet showInView: self.subtitleSwitcherButton];
...@@ -654,15 +661,11 @@ ...@@ -654,15 +661,11 @@
if (buttonIndex == [actionSheet cancelButtonIndex]) if (buttonIndex == [actionSheet cancelButtonIndex])
return; return;
NSUInteger arrayIndex = 0;
NSArray *indexArray; NSArray *indexArray;
NSArray *namesArray;
if (actionSheet == _subtitleActionSheet) { if (actionSheet == _subtitleActionSheet) {
namesArray = _mediaPlayer.videoSubTitlesNames; indexArray = _mediaPlayer.videoSubTitlesIndexes;
arrayIndex = [namesArray indexOfObject:[actionSheet buttonTitleAtIndex:buttonIndex]]; if (buttonIndex <= indexArray.count) {
if (arrayIndex != NSNotFound) { _mediaPlayer.currentVideoSubTitleIndex = [indexArray[buttonIndex] intValue];
indexArray = _mediaPlayer.videoSubTitlesIndexes;
_mediaPlayer.currentVideoSubTitleIndex = [indexArray[arrayIndex] intValue];
} }
} else if (actionSheet == _audiotrackActionSheet) { } else if (actionSheet == _audiotrackActionSheet) {
indexArray = _mediaPlayer.audioTrackIndexes; indexArray = _mediaPlayer.audioTrackIndexes;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment