Sfoglia il codice sorgente

Add S/PDIF option

(cherry picked from commit 8249ac00d3defbaca9c7e9b82fb0384622b2c05d)
Felix Paul Kühne 9 anni fa
parent
commit
aef26eb557

+ 25 - 12
Apple-TV/Playback/Playback Info/VLCPlaybackInfoTracksTVViewController.m

@@ -97,24 +97,27 @@
 @implementation VLCPlaybackInfoTracksDataSourceAudio
 - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
 {
-    return self.mediaPlayer.numberOfAudioTracks;
+    return self.mediaPlayer.numberOfAudioTracks + 1;
 }
 
 - (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath
 {
     VLCPlaybackInfoTVCollectionViewCell *trackCell = (VLCPlaybackInfoTVCollectionViewCell*)cell;
     NSInteger row = indexPath.row;
-    BOOL isSelected = NO;
     NSArray *audioTrackIndexes = self.mediaPlayer.audioTrackIndexes;
-    if (row < audioTrackIndexes.count) {
-        isSelected = [audioTrackIndexes[row] intValue] == self.mediaPlayer.currentAudioTrackIndex;
-    }
-    trackCell.selectionMarkerVisible = isSelected;
+    NSString *trackName;
+    if (row >= audioTrackIndexes.count) {
+        trackName = NSLocalizedString(@"USE_SPDIF", nil);
+        trackCell.selectionMarkerVisible = [[NSUserDefaults standardUserDefaults] boolForKey:kVLCSettingUseSPDIF];
+    } else {
+        BOOL isSelected = [audioTrackIndexes[row] intValue] == self.mediaPlayer.currentVideoSubTitleIndex;
+        trackCell.selectionMarkerVisible = isSelected;
 
-    NSString *trackName = self.mediaPlayer.audioTrackNames[row];
-    if (trackName != nil) {
-        if ([trackName isEqualToString:@"Disable"])
-            trackName = NSLocalizedString(@"DISABLE_LABEL", nil);
+        trackName = self.mediaPlayer.audioTrackNames[row];
+        if (trackName != nil) {
+            if ([trackName isEqualToString:@"Disable"])
+                trackName = NSLocalizedString(@"DISABLE_LABEL", nil);
+        }
     }
     trackCell.titleLabel.text = trackName;
 }
@@ -123,7 +126,17 @@
 {
     NSArray *audioTrackIndexes = self.mediaPlayer.audioTrackIndexes;
     NSInteger row = indexPath.row;
-    if (row < audioTrackIndexes.count) {
+    if (row >= audioTrackIndexes.count) {
+        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+        BOOL bValue = ![defaults boolForKey:kVLCSettingUseSPDIF];
+        [[VLCPlaybackController sharedInstance].mediaPlayer performSelector:@selector(setPassthroughAudio:) withObject:@(bValue)];
+        [defaults setBool:bValue forKey:kVLCSettingUseSPDIF];
+        [defaults synchronize];
+        /* restart the audio output */
+        int currentAudioTrackIndex = self.mediaPlayer.currentAudioTrackIndex;
+        self.mediaPlayer.currentAudioTrackIndex = -1;
+        self.mediaPlayer.currentAudioTrackIndex = currentAudioTrackIndex;
+    } else {
         self.mediaPlayer.currentAudioTrackIndex = [audioTrackIndexes[row] intValue];
     }
     [collectionView reloadData];
@@ -145,7 +158,7 @@
     if (row >= spuTitleIndexes.count) {
         trackName = NSLocalizedString(@"DOWNLOAD_SUBS_FROM_OSO", nil);
     } else {
-        BOOL isSelected = [self.mediaPlayer.videoSubTitlesIndexes[row] intValue] == self.mediaPlayer.currentVideoSubTitleIndex;
+        BOOL isSelected = [spuTitleIndexes[row] intValue] == self.mediaPlayer.currentVideoSubTitleIndex;
         trackCell.selectionMarkerVisible = isSelected;
 
         trackName = self.mediaPlayer.videoSubTitlesNames[row];

+ 1 - 0
Apple-TV/VLCTVConstants.h

@@ -58,6 +58,7 @@
 #define kVLCSettingSaveHTTPUploadServerStatus @"isHTTPServerOn"
 #define kVLCAutomaticallyPlayNextItem @"AutomaticallyPlayNextItem"
 #define kVLCSettingDownloadArtwork @"download-artwork"
+#define kVLCSettingUseSPDIF @"kVLCSettingUseSPDIF"
 
 #define kVLCSettingLastUsedSubtitlesSearchLanguage @"kVLCSettingLastUsedSubtitlesSearchLanguage"
 #define kVLCSettingWiFiSharingIPv6 @"wifi-sharing-ipv6"

+ 1 - 0
NEWS

@@ -15,6 +15,7 @@ iOS 2.7.3:
 tvOS 1.0.3:
 -----------
 * General stability improvements and bug fixes
+* Added S/PDIF pass-through option
 * Added option to disable artwork retrieval
 * Added automatic finding of external subtitles on HTTP, FTP, PLEX and UPnP
   - Note that SMB shares are not supported yet.

+ 1 - 0
Resources/en.lproj/Localizable.strings

@@ -312,6 +312,7 @@
 "CACHED_MEDIA_LONG"="Media shown here is stored locally on your Apple TV. Note that contents can be removed by the operating system without prior notice anytime when VLC is not running in case your device runs out of storage.";
 "DOWNLOAD_SUBS_FROM_OSO"="Download subtitles from OpenSubtitles.org...";
 "FOUND_SUBS"="Found subtitles";
+"USE_SPDIF"="Use S/PDIF";
 
 // Local Network Service Names
 "UPNP_LONG"="Universal Plug'n'Play (UPnP)";