Commit 4de5572d authored by Carola Nitz's avatar Carola Nitz

VLCPlaybackInfoCollectionViewDataSource: remove knowledge of Mediaplayer

parent c879807d
......@@ -97,18 +97,19 @@
@implementation VLCPlaybackInfoTitlesDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return self.mediaPlayer.numberOfTitles;
return [[VLCPlaybackController sharedInstance] numberOfTitles];
}
- (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath
{
VLCPlaybackInfoTVCollectionViewCell *trackCell = (VLCPlaybackInfoTVCollectionViewCell*)cell;
NSInteger row = indexPath.row;
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
BOOL isSelected = self.mediaPlayer.currentTitleIndex == row;
BOOL isSelected = [vpc indexOfCurrentTitle] == row;
trackCell.selectionMarkerVisible = isSelected;
NSDictionary *description = self.mediaPlayer.titleDescriptions[row];
NSDictionary *description = [vpc titleDescriptionsDictAtIndex:row];
NSString *title = description[VLCTitleDescriptionName];
if (title == nil)
title = [NSString stringWithFormat:@"%@ %li", NSLocalizedString(@"TITLE", nil), row];
......@@ -118,7 +119,7 @@
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
self.mediaPlayer.currentTitleIndex = (int)indexPath.row;
[[VLCPlaybackController sharedInstance] selectTitleAtIndex:indexPath.row];
[collectionView reloadData];
[self.dependendCollectionView reloadData];
}
......@@ -127,33 +128,30 @@
@implementation VLCPlaybackInfoChaptersDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
VLCMediaPlayer *player = self.mediaPlayer;
return [player numberOfChaptersForTitle:player.currentTitleIndex];
return [[VLCPlaybackController sharedInstance] numberOfChaptersForCurrentTitle];
}
- (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath
{
VLCPlaybackInfoTVCollectionViewCell *trackCell = (VLCPlaybackInfoTVCollectionViewCell*)cell;
NSInteger row = indexPath.row;
VLCMediaPlayer *player = self.mediaPlayer;
BOOL isSelected = player.currentChapterIndex == row;
BOOL isSelected = [[VLCPlaybackController sharedInstance] indexOfCurrentChapter] == row;
trackCell.selectionMarkerVisible = isSelected;
NSArray *chapterDescriptions = [player chapterDescriptionsOfTitle:player.currentTitleIndex];
if (row < chapterDescriptions.count) {
NSDictionary *description = chapterDescriptions[row];
NSString *chapter = description[VLCChapterDescriptionName];
if (chapter == nil)
chapter = [NSString stringWithFormat:@"%@ %li", NSLocalizedString(@"CHAPTER", nil), row];
NSString *chapterTitle = [NSString stringWithFormat:@"%@ (%@)", chapter, [[VLCTime timeWithNumber:description[VLCChapterDescriptionDuration]] stringValue]];
trackCell.titleLabel.text = chapterTitle;
}
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
NSDictionary *description = [vpc chapterDescriptionsDictAtIndex:[vpc indexOfCurrentTitle]];
NSString *chapter = description[VLCChapterDescriptionName];
if (chapter == nil)
chapter = [NSString stringWithFormat:@"%@ %li", NSLocalizedString(@"CHAPTER", nil), row];
NSString *chapterTitle = [NSString stringWithFormat:@"%@ (%@)", chapter, [[VLCTime timeWithNumber:description[VLCChapterDescriptionDuration]] stringValue]];
trackCell.titleLabel.text = chapterTitle;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
self.mediaPlayer.currentChapterIndex = (int)indexPath.row;
[[VLCPlaybackController sharedInstance] selectChapterAtIndex:indexPath.row];
[collectionView reloadData];
}
......
......@@ -12,10 +12,9 @@
#import <Foundation/Foundation.h>
@interface VLCPlaybackInfoCollectionViewDataSource : NSObject
@property (nonatomic, readonly) VLCMediaPlayer *mediaPlayer;
@property (nonatomic) NSString *title;
@property (nonatomic) NSString *cellIdentifier;
@property (nonatomic) UIViewController *parentViewController;
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath;
@end
\ No newline at end of file
@end
......@@ -14,11 +14,6 @@
@implementation VLCPlaybackInfoCollectionViewDataSource
- (VLCMediaPlayer *)mediaPlayer
{
return [VLCPlaybackController sharedInstance].mediaPlayer;
}
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
VLCPlaybackInfoTVCollectionSectionTitleView *header = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:[VLCPlaybackInfoTVCollectionSectionTitleView identifier] forIndexPath:indexPath];
......
......@@ -97,29 +97,29 @@
@implementation VLCPlaybackInfoTracksDataSourceAudio
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return self.mediaPlayer.numberOfAudioTracks + 1;
return [[VLCPlaybackController sharedInstance] numberOfAudioTracks] + 1;
}
- (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath
{
VLCPlaybackInfoTVCollectionViewCell *trackCell = (VLCPlaybackInfoTVCollectionViewCell*)cell;
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
NSInteger row = indexPath.row;
NSArray *audioTrackIndexes = self.mediaPlayer.audioTrackIndexes;
NSString *trackName;
trackCell.titleLabel.font = [UIFont boldSystemFontOfSize:29.];
if (row >= audioTrackIndexes.count) {
if (row >= [vpc numberOfAudioTracks]) {
if ([[NSUserDefaults standardUserDefaults] boolForKey:kVLCSettingUseSPDIF]) {
trackName = [@"✓ " stringByAppendingString:NSLocalizedString(@"USE_SPDIF", nil)];
trackCell.titleLabel.font = [UIFont boldSystemFontOfSize:29.];
} else
trackName = NSLocalizedString(@"USE_SPDIF", nil);
} else {
BOOL isSelected = [audioTrackIndexes[row] intValue] == self.mediaPlayer.currentAudioTrackIndex;
BOOL isSelected = row == [vpc indexOfCurrentAudioTrack];
trackCell.selectionMarkerVisible = isSelected;
trackName = self.mediaPlayer.audioTrackNames[row];
trackName = [vpc audioTrackNameAtIndex:row];
if (trackName != nil) {
if ([trackName isEqualToString:@"Disable"])
trackName = NSLocalizedString(@"DISABLE_LABEL", nil);
......@@ -128,23 +128,23 @@
trackCell.titleLabel.text = trackName;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
NSArray *audioTrackIndexes = self.mediaPlayer.audioTrackIndexes;
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
NSInteger row = indexPath.row;
if (row >= audioTrackIndexes.count) {
if (row >= [vpc numberOfAudioTracks]) {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
BOOL bValue = ![defaults boolForKey:kVLCSettingUseSPDIF];
self.mediaPlayer.audio.passthrough = bValue;
[vpc setAudioPassthrough: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;
NSInteger currentAudioTrackIndex = [vpc indexOfCurrentAudioTrack];
[vpc selectAudioTrackAtIndex:0];
[vpc selectAudioTrackAtIndex:currentAudioTrackIndex];
} else {
self.mediaPlayer.currentAudioTrackIndex = [audioTrackIndexes[row] intValue];
[vpc selectAudioTrackAtIndex:row];
}
[collectionView reloadData];
}
......@@ -154,22 +154,22 @@
@implementation VLCPlaybackInfoTracksDataSourceSubtitle
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return self.mediaPlayer.numberOfSubtitlesTracks + 1;
return [[VLCPlaybackController sharedInstance] numberOfVideoSubtitlesIndexes] + 1;
}
- (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath
{
VLCPlaybackInfoTVCollectionViewCell *trackCell = (VLCPlaybackInfoTVCollectionViewCell*)cell;
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
NSInteger row = indexPath.row;
NSArray *spuTitleIndexes = self.mediaPlayer.videoSubTitlesIndexes;
NSString *trackName;
if (row >= spuTitleIndexes.count) {
if (row >= [vpc numberOfVideoSubtitlesIndexes]) {
trackName = NSLocalizedString(@"DOWNLOAD_SUBS_FROM_OSO", nil);
} else {
BOOL isSelected = [spuTitleIndexes[row] intValue] == self.mediaPlayer.currentVideoSubTitleIndex;
BOOL isSelected = [vpc indexOfCurrentSubtitleTrack] == row;
trackCell.selectionMarkerVisible = isSelected;
trackName = self.mediaPlayer.videoSubTitlesNames[row];
trackName = [vpc videoSubtitleNameAtIndex:row];
if (trackName != nil) {
if ([trackName isEqualToString:@"Disable"])
trackName = NSLocalizedString(@"DISABLE_LABEL", nil);
......@@ -180,16 +180,16 @@
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
NSArray *spuTitleIndexes = self.mediaPlayer.videoSubTitlesIndexes;
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
NSInteger row = indexPath.row;
if (row >= spuTitleIndexes.count) {
if (row >= [vpc numberOfVideoSubtitlesIndexes]) {
if (self.parentViewController) {
if ([self.parentViewController respondsToSelector:@selector(downloadMoreSPU)]) {
[self.parentViewController performSelector:@selector(downloadMoreSPU)];
}
}
} else {
self.mediaPlayer.currentVideoSubTitleIndex = [self.mediaPlayer.videoSubTitlesIndexes[row] intValue];
[vpc selectVideoSubtitleAtIndex:row];
[collectionView reloadData];
}
}
......
......@@ -41,7 +41,6 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
@interface VLCPlaybackController : NSObject <VLCEqualizerViewDelegate>
@property (nonatomic, readonly) VLCMediaListPlayer *listPlayer;
@property (nonatomic, readonly) VLCMediaPlayer *mediaPlayer;
@property (nonatomic, strong) UIView *videoOutputView;
......@@ -111,6 +110,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
- (void)selectVideoSubtitleAtIndex:(NSInteger)index;
- (void)selectTitleAtIndex:(NSInteger)index;
- (void)selectChapterAtIndex:(NSInteger)index;
- (void)setAudioPassthrough:(BOOL)shouldPass;
- (void)switchAspectRatio;
- (BOOL)updateViewpoint:(CGFloat)yaw pitch:(CGFloat)pitch roll:(CGFloat)roll fov:(CGFloat)fov absolute:(BOOL)absolute;
......
......@@ -688,6 +688,11 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
return [_mediaPlayer remainingTime];
}
- (void)setAudioPassthrough:(BOOL)shouldPass
{
_mediaPlayer.audio.passthrough = shouldPass;
}
- (void)mediaPlayerStateChanged:(NSNotification *)aNotification
{
VLCMediaPlayerState currentState = _mediaPlayer.state;
......
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