Commit a39698e9 authored by Tobias's avatar Tobias

add property for VLCPlaybackController in VLCMoviewController and use that...

add property for VLCPlaybackController in VLCMoviewController and use that instead of getting the shared instance everywhere vpc is used
parent 31988149
...@@ -84,6 +84,8 @@ ...@@ -84,6 +84,8 @@
@property (nonatomic, strong) IBOutlet UILabel *trackNameLabel; @property (nonatomic, strong) IBOutlet UILabel *trackNameLabel;
@property (nonatomic, strong) IBOutlet UIImageView *artworkImageView; @property (nonatomic, strong) IBOutlet UIImageView *artworkImageView;
@property (nonatomic, weak) IBOutlet VLCPlaybackController *playbackController;
- (IBAction)closePlayback:(id)sender; - (IBAction)closePlayback:(id)sender;
- (IBAction)positionSliderAction:(id)sender; - (IBAction)positionSliderAction:(id)sender;
......
...@@ -342,7 +342,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) { ...@@ -342,7 +342,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
} else { } else {
_equalizerView = [[VLCEqualizerView alloc] initWithFrame:CGRectMake((rect.size.width - 450.) / 2., self.controllerPanel.frame.origin.y - 240., 450., 240.)]; _equalizerView = [[VLCEqualizerView alloc] initWithFrame:CGRectMake((rect.size.width - 450.) / 2., self.controllerPanel.frame.origin.y - 240., 450., 240.)];
} }
_equalizerView.delegate = [VLCPlaybackController sharedInstance]; _equalizerView.delegate = self.playbackController;
_equalizerView.UIdelegate = self; _equalizerView.UIdelegate = self;
_equalizerView.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin; _equalizerView.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin;
_equalizerView.hidden = YES; _equalizerView.hidden = YES;
...@@ -410,7 +410,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) { ...@@ -410,7 +410,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackTranslucent; [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackTranslucent;
} }
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCPlaybackController *vpc = self.playbackController;
vpc.delegate = self; vpc.delegate = self;
vpc.presentingMovieViewController = YES; vpc.presentingMovieViewController = YES;
[vpc recoverPlaybackState]; [vpc recoverPlaybackState];
...@@ -423,7 +423,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) { ...@@ -423,7 +423,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
[super viewDidAppear:animated]; [super viewDidAppear:animated];
_viewAppeared = YES; _viewAppeared = YES;
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCPlaybackController *vpc = self.playbackController;
[vpc recoverDisplayedMetadata]; [vpc recoverDisplayedMetadata];
vpc.videoOutputView = nil; vpc.videoOutputView = nil;
vpc.videoOutputView = self.movieView; vpc.videoOutputView = self.movieView;
...@@ -471,7 +471,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) { ...@@ -471,7 +471,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
- (void)viewWillDisappear:(BOOL)animated - (void)viewWillDisappear:(BOOL)animated
{ {
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCPlaybackController *vpc = self.playbackController;
vpc.videoOutputView = nil; vpc.videoOutputView = nil;
vpc.presentingMovieViewController = NO; vpc.presentingMovieViewController = NO;
...@@ -682,8 +682,8 @@ typedef NS_ENUM(NSInteger, VLCPanType) { ...@@ -682,8 +682,8 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
- (void)_setPositionForReal - (void)_setPositionForReal
{ {
if (!_positionSet) { if (!_positionSet) {
[VLCPlaybackController sharedInstance].mediaPlayer.position = self.timeNavigationTitleView.positionSlider.value; self.playbackController.mediaPlayer.position = self.timeNavigationTitleView.positionSlider.value;
[[VLCPlaybackController sharedInstance] setNeedsMetadataUpdate]; [self.playbackController setNeedsMetadataUpdate];
_positionSet = YES; _positionSet = YES;
} }
} }
...@@ -736,6 +736,14 @@ typedef NS_ENUM(NSInteger, VLCPanType) { ...@@ -736,6 +736,14 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
#pragma mark - playback controller delegation #pragma mark - playback controller delegation
- (VLCPlaybackController *)playbackController
{
if (!_playbackController) {
_playbackController = [VLCPlaybackController sharedInstance];
}
return _playbackController;
}
- (void)playbackPositionUpdated:(VLCPlaybackController *)controller - (void)playbackPositionUpdated:(VLCPlaybackController *)controller
{ {
VLCMediaPlayer *mediaPlayer = controller.mediaPlayer; VLCMediaPlayer *mediaPlayer = controller.mediaPlayer;
...@@ -851,21 +859,21 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -851,21 +859,21 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
{ {
LOCKCHECK; LOCKCHECK;
[[VLCPlaybackController sharedInstance] playPause]; [self.playbackController playPause];
} }
- (IBAction)forward:(id)sender - (IBAction)forward:(id)sender
{ {
LOCKCHECK; LOCKCHECK;
[[VLCPlaybackController sharedInstance] forward]; [self.playbackController forward];
} }
- (IBAction)backward:(id)sender - (IBAction)backward:(id)sender
{ {
LOCKCHECK; LOCKCHECK;
[[VLCPlaybackController sharedInstance] backward]; [self.playbackController backward];
} }
- (IBAction)switchTrack:(id)sender - (IBAction)switchTrack:(id)sender
...@@ -1042,7 +1050,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -1042,7 +1050,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
{ {
LOCKCHECK; LOCKCHECK;
VLCMediaListPlayer *listPlayer = [VLCPlaybackController sharedInstance].listPlayer; VLCMediaListPlayer *listPlayer = self.playbackController.listPlayer;
if (listPlayer.repeatMode == VLCDoNotRepeat) { if (listPlayer.repeatMode == VLCDoNotRepeat) {
listPlayer.repeatMode = VLCRepeatCurrentItem; listPlayer.repeatMode = VLCRepeatCurrentItem;
...@@ -1068,7 +1076,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -1068,7 +1076,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{ {
NSInteger ret = 0; NSInteger ret = 0;
VLCMediaPlayer *mediaPlayer = [VLCPlaybackController sharedInstance].mediaPlayer; VLCMediaPlayer *mediaPlayer = self.playbackController.mediaPlayer;
if (_switchingTracksNotChapters == YES) { if (_switchingTracksNotChapters == YES) {
if (mediaPlayer.audioTrackIndexes.count > 2) if (mediaPlayer.audioTrackIndexes.count > 2)
...@@ -1099,7 +1107,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -1099,7 +1107,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{ {
VLCMediaPlayer *mediaPlayer = [VLCPlaybackController sharedInstance].mediaPlayer; VLCMediaPlayer *mediaPlayer = self.playbackController.mediaPlayer;
if (_switchingTracksNotChapters == YES) { if (_switchingTracksNotChapters == YES) {
if (mediaPlayer.audioTrackIndexes.count > 2 && section == 0) if (mediaPlayer.audioTrackIndexes.count > 2 && section == 0)
...@@ -1127,7 +1135,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -1127,7 +1135,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
NSInteger row = indexPath.row; NSInteger row = indexPath.row;
NSInteger section = indexPath.section; NSInteger section = indexPath.section;
VLCMediaPlayer *mediaPlayer = [VLCPlaybackController sharedInstance].mediaPlayer; VLCMediaPlayer *mediaPlayer = self.playbackController.mediaPlayer;
if (_switchingTracksNotChapters == YES) { if (_switchingTracksNotChapters == YES) {
NSArray *indexArray; NSArray *indexArray;
...@@ -1173,7 +1181,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -1173,7 +1181,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{ {
VLCMediaPlayer *mediaPlayer = [VLCPlaybackController sharedInstance].mediaPlayer; VLCMediaPlayer *mediaPlayer = self.playbackController.mediaPlayer;
if (_switchingTracksNotChapters == YES) { if (_switchingTracksNotChapters == YES) {
NSInteger audioTrackCount = mediaPlayer.audioTrackIndexes.count; NSInteger audioTrackCount = mediaPlayer.audioTrackIndexes.count;
...@@ -1194,7 +1202,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -1194,7 +1202,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
{ {
[tableView deselectRowAtIndexPath:indexPath animated:NO]; [tableView deselectRowAtIndexPath:indexPath animated:NO];
NSInteger index = indexPath.row; NSInteger index = indexPath.row;
VLCMediaPlayer *mediaPlayer = [VLCPlaybackController sharedInstance].mediaPlayer; VLCMediaPlayer *mediaPlayer = self.playbackController.mediaPlayer;
if (_switchingTracksNotChapters == YES) { if (_switchingTracksNotChapters == YES) {
NSArray *indexArray; NSArray *indexArray;
...@@ -1241,7 +1249,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -1241,7 +1249,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
if (!_swipeGesturesEnabled) if (!_swipeGesturesEnabled)
return; return;
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCPlaybackController *vpc = self.playbackController;
if ([vpc.mediaPlayer isPlaying]) { if ([vpc.mediaPlayer isPlaying]) {
[vpc.listPlayer pause]; [vpc.listPlayer pause];
...@@ -1293,7 +1301,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -1293,7 +1301,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
_currentPanType = [self detectPanTypeForPan:panRecognizer]; _currentPanType = [self detectPanTypeForPan:panRecognizer];
if (_currentPanType == VLCPanTypeSeek) { if (_currentPanType == VLCPanTypeSeek) {
VLCMediaPlayer *mediaPlayer = [VLCPlaybackController sharedInstance].mediaPlayer; VLCMediaPlayer *mediaPlayer = self.playbackController.mediaPlayer;
double timeRemainingDouble = (-mediaPlayer.remainingTime.intValue*0.001); double timeRemainingDouble = (-mediaPlayer.remainingTime.intValue*0.001);
int timeRemaining = timeRemainingDouble; int timeRemaining = timeRemainingDouble;
...@@ -1332,7 +1340,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -1332,7 +1340,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
} }
if (panRecognizer.state == UIGestureRecognizerStateEnded) { if (panRecognizer.state == UIGestureRecognizerStateEnded) {
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCPlaybackController *vpc = self.playbackController;
_currentPanType = VLCPanTypeNone; _currentPanType = VLCPanTypeNone;
if ([vpc.mediaPlayer isPlaying]) if ([vpc.mediaPlayer isPlaying])
[vpc.listPlayer play]; [vpc.listPlayer play];
...@@ -1347,7 +1355,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -1347,7 +1355,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
return; return;
NSString * hudString = @" "; NSString * hudString = @" ";
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCPlaybackController *vpc = self.playbackController;
VLCMediaPlayer *mediaPlayer = vpc.mediaPlayer; VLCMediaPlayer *mediaPlayer = vpc.mediaPlayer;
if (swipeRecognizer.direction == UISwipeGestureRecognizerDirectionRight) { if (swipeRecognizer.direction == UISwipeGestureRecognizerDirectionRight) {
...@@ -1402,7 +1410,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -1402,7 +1410,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
- (IBAction)videoFilterSliderAction:(id)sender - (IBAction)videoFilterSliderAction:(id)sender
{ {
VLCMediaPlayer *mediaPlayer = [VLCPlaybackController sharedInstance].mediaPlayer; VLCMediaPlayer *mediaPlayer = self.playbackController.mediaPlayer;
if (sender == self.hueSlider) if (sender == self.hueSlider)
mediaPlayer.hue = (int)self.hueSlider.value; mediaPlayer.hue = (int)self.hueSlider.value;
...@@ -1433,7 +1441,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -1433,7 +1441,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
- (IBAction)playbackSliderAction:(UISlider *)sender - (IBAction)playbackSliderAction:(UISlider *)sender
{ {
LOCKCHECK; LOCKCHECK;
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance]; VLCPlaybackController *vpc = self.playbackController;
if (sender == _playbackSpeedSlider) { if (sender == _playbackSpeedSlider) {
double speed = exp2(sender.value); double speed = exp2(sender.value);
...@@ -1464,7 +1472,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom ...@@ -1464,7 +1472,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
_playbackSpeedViewHidden = self.playbackSpeedView.hidden; _playbackSpeedViewHidden = self.playbackSpeedView.hidden;
[self _resetIdleTimer]; [self _resetIdleTimer];
} else if (sender == self.timeNavigationTitleView.aspectRatioButton) { } else if (sender == self.timeNavigationTitleView.aspectRatioButton) {
[[VLCPlaybackController sharedInstance] switchAspectRatio]; [self.playbackController switchAspectRatio];
} }
} }
......
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