Skip to content

Commit

Permalink
exposes methods
Browse files Browse the repository at this point in the history
  • Loading branch information
priore committed May 2, 2016
1 parent 48f8657 commit fdfcb7f
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 3 deletions.
2 changes: 1 addition & 1 deletion AVPlayerOverlay.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'AVPlayerOverlay'
s.version = '1.0'
s.version = '1.1'
s.summary = 'AVPlayer with custom controls and full screen features.'
s.license = 'MIT'
s.ios.platform = '7.1'
Expand Down
21 changes: 21 additions & 0 deletions AVPlayerOverlay/AVPlayer/AVPlayerOverlayVC.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,26 @@
@property (nonatomic, weak) IBOutlet UISlider *volumeSlider;

@property (nonatomic, weak) AVPlayer *player;
@property (nonatomic, assign) BOOL isFullscreen;

- (void)updateProgressBar;

- (void)autoHidePlayerBar;
- (void)hidePlayerBar;
- (void)showPlayerBar;

- (void)didTapGesture:(id)sender;
- (void)didPlayButtonSelected:(id)sender;
- (void)didVolumeButtonSelected:(id)sender;
- (void)didFullscreenButtonSelected:(id)sender;

- (void)didVolumeSliderValueChanged:(id)sender;

- (void)didVideoSliderTouchUp:(id)sender;
- (void)didVideoSliderTouchDown:(id)sender;
- (void)videoSliderEnabled:(BOOL)enabled;

- (void)didFullScreenModeFromParentViewController:(UIViewController*)parent;
- (void)didNormalScreenModeToParentViewController:(UIViewController*)parent;

@end
37 changes: 36 additions & 1 deletion AVPlayerOverlay/AVPlayer/AVPlayerOverlayVC.m
Original file line number Diff line number Diff line change
Expand Up @@ -241,18 +241,25 @@ - (void)didVolumeButtonSelected:(id)sender

- (void)didFullscreenButtonSelected:(id)sender
{
static BOOL navbar;
static BOOL statusbar;
static CGRect current_frame;
static UIView *container_view;
static UIWindow *mainWindow;
static UIViewController *original_parent;

UIViewController *parent = self.parentViewController; // AVPlayerViewController
UIWindow *mainWindow = [UIApplication sharedApplication].keyWindow;

if (mainWindow == nil)
mainWindow = [UIApplication sharedApplication].keyWindow;

if (_window == nil)
{
statusbar = [UIApplication sharedApplication].isStatusBarHidden;
original_parent = parent.parentViewController;
current_frame = [parent.view convertRect:parent.view.frame toView:mainWindow];
container_view = parent.view.superview;
navbar = parent.navigationController.isNavigationBarHidden;

[parent removeFromParentViewController];
[parent.view removeFromSuperview];
Expand All @@ -267,16 +274,25 @@ - (void)didFullscreenButtonSelected:(id)sender

_window.rootViewController = parent;

[self didFullScreenModeFromParentViewController:parent];

[UIView animateKeyframesWithDuration:0.5
delay:0
options:UIViewKeyframeAnimationOptionLayoutSubviews
animations:^{
_window.frame = mainWindow.bounds;
} completion:^(BOOL finished) {
_fullscreenButton.transform = CGAffineTransformMakeScale(-1.0, -1.0);
_isFullscreen = YES;
}];

[self.navigationController setNavigationBarHidden:YES animated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];

} else {

[self didNormalScreenModeToParentViewController:parent];

[UIView animateKeyframesWithDuration:0.5
delay:0
options:UIViewKeyframeAnimationOptionLayoutSubviews
Expand All @@ -292,12 +308,31 @@ - (void)didFullscreenButtonSelected:(id)sender
[parent didMoveToParentViewController:self];

[_window removeFromSuperview], self.window = nil;
[mainWindow makeKeyAndVisible];

_isFullscreen = NO;
}];

[self.navigationController setNavigationBarHidden:navbar animated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:statusbar withAnimation:UIStatusBarAnimationSlide];

}

[self autoHidePlayerBar];
}

#pragma mark - Overridable Methods

- (void)didFullScreenModeFromParentViewController:(UIViewController*)parent
{

}

- (void)didNormalScreenModeToParentViewController:(UIViewController*)parent
{

}

#pragma mark - Volume Slider

- (void)didVolumeSliderValueChanged:(id)sender
Expand Down
2 changes: 2 additions & 0 deletions AVPlayerOverlay/AVPlayer/AVPlayerVC.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@

#import <AVKit/AVKit.h>

IB_DESIGNABLE
@interface AVPlayerVC : AVPlayerViewController

@property (nonatomic, strong) NSURL *videoURL;
@property (nonatomic, strong) IBInspectable NSString *overlayStoryboardId;

@end
12 changes: 11 additions & 1 deletion AVPlayerOverlay/AVPlayer/AVPlayerVC.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ @interface AVPlayerVC()

@implementation AVPlayerVC

- (instancetype)init
{
if (self = [super init]) {

_overlayStoryboardId = @"AVPlayerOverlayVC";
}

return self;
}

- (void)viewDidLoad
{
[super viewDidLoad];
Expand All @@ -31,7 +41,7 @@ - (void)viewDidLoad
self.videoURL = note.object;
}];

_overlayVC = [self.storyboard instantiateViewControllerWithIdentifier:@"AVPlayerOverlayVC"];
_overlayVC = [self.storyboard instantiateViewControllerWithIdentifier:_overlayStoryboardId];

[self addChildViewController:_overlayVC];
[self.view addSubview:_overlayVC.view];
Expand Down

0 comments on commit fdfcb7f

Please sign in to comment.