Skip to content
This repository was archived by the owner on Jul 22, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions Code/VideoPlayerKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
@property (readwrite, strong) AVPlayer *videoPlayer;

- (void)playVideoWithTitle:(NSString *)title URL:(NSURL *)url videoID:(NSString *)videoID shareURL:(NSURL *)shareURL isStreaming:(BOOL)streaming playInFullScreen:(BOOL)playInFullScreen;
- (void)playVideoWithTitle:(NSString *)title URL:(NSURL *)url videoID:(NSString *)videoID shareURL:(NSURL *)shareURL isStreaming:(BOOL)streaming playInFullScreen:(BOOL)playInFullScreen isAlwaysFullscreen:(BOOL)isAlwaysFullscreen;
- (void)syncFullScreenButton:(UIInterfaceOrientation)toInterfaceOrientation;
- (void)showCannotFetchStreamError;
- (void)launchFullScreen;
Expand Down
101 changes: 67 additions & 34 deletions Code/VideoPlayerKit.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ @interface VideoPlayerKit () <UIGestureRecognizerDelegate>
@property (nonatomic) CGRect previousBounds;
@property (nonatomic) BOOL hideTopViewWithControls;


@end

@implementation VideoPlayerKit {
Expand Down Expand Up @@ -125,6 +126,7 @@ - (void)loadView
self.videoPlayerView = [[VideoPlayerView alloc] initWithFrame:CGRectZero];
}
self.view = self.videoPlayerView;
self.view.backgroundColor = [UIColor blackColor];
}

- (void)viewDidLoad
Expand Down Expand Up @@ -188,7 +190,7 @@ - (void)shareButtonHandler
}
}

- (void)playVideoWithTitle:(NSString *)title URL:(NSURL *)url videoID:(NSString *)videoID shareURL:(NSURL *)shareURL isStreaming:(BOOL)streaming playInFullScreen:(BOOL)playInFullScreen
- (void)playVideoWithTitle:(NSString *)title URL:(NSURL *)url videoID:(NSString *)videoID shareURL:(NSURL *)shareURL isStreaming:(BOOL)streaming playInFullScreen:(BOOL)playInFullScreen isAlwaysFullscreen:(BOOL)isAlwaysFullscreen
{
[self.videoPlayer pause];

Expand Down Expand Up @@ -225,10 +227,22 @@ - (void)playVideoWithTitle:(NSString *)title URL:(NSURL *)url videoID:(NSString

[self syncPlayPauseButtons];

self.isAlwaysFullscreen = isAlwaysFullscreen;

if (playInFullScreen) {
self.isAlwaysFullscreen = YES;
[self launchFullScreen];
}
else
{
self.fullScreenModeToggled = YES;
self.previousBounds = self.view.bounds;
[self minimizeVideo];
}
}

- (void)playVideoWithTitle:(NSString *)title URL:(NSURL *)url videoID:(NSString *)videoID shareURL:(NSURL *)shareURL isStreaming:(BOOL)streaming playInFullScreen:(BOOL)playInFullScreen
{
[self playVideoWithTitle:title URL:url videoID:videoID shareURL:shareURL isStreaming:streaming playInFullScreen:playInFullScreen isAlwaysFullscreen:YES];
}

- (void)showCannotFetchStreamError
Expand Down Expand Up @@ -265,24 +279,27 @@ - (void)launchFullScreen
if (!self.fullScreenModeToggled) {
self.fullScreenModeToggled = YES;

if (!self.isAlwaysFullscreen) {
[self hideControlsAnimated:YES];
}

[self syncFullScreenButton:[[UIApplication sharedApplication] statusBarOrientation]];

if (!self.fullscreenViewController) {
self.fullscreenViewController = [[FullScreenViewController alloc] init];
self.fullscreenViewController.allowPortraitFullscreen = self.allowPortraitFullscreen;
if (self.isAlwaysFullscreen)
{
if (!self.fullscreenViewController) {
self.fullscreenViewController = [[FullScreenViewController alloc] init];
self.fullscreenViewController.allowPortraitFullscreen = self.allowPortraitFullscreen;
}

[self.videoPlayerView setFullscreen:YES];
[self.fullscreenViewController.view addSubview:self.videoPlayerView];
}
else
{
[self.videoPlayerView setFullscreen:YES];
}

[self.videoPlayerView setFullscreen:YES];
[self.fullscreenViewController.view addSubview:self.videoPlayerView];


if (self.topView) {
[self.topView removeFromSuperview];
[self.fullscreenViewController.view addSubview:self.topView];
[self.videoPlayerView addSubview:self.topView];
}

if (self.isAlwaysFullscreen) {
Expand All @@ -299,8 +316,9 @@ - (void)launchFullScreen
completion:nil];
}

[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:self.fullscreenViewController animated:YES completion:^{
if (self.isAlwaysFullscreen) {
if (self.isAlwaysFullscreen)
{
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:self.fullscreenViewController animated:YES completion:^{
self.videoPlayerView.frame = CGRectMake(self.videoPlayerView.superview.bounds.size.width / 2, self.videoPlayerView.superview.bounds.size.height / 2, 0, 0);
self.previousBounds = CGRectMake(self.videoPlayerView.superview.bounds.size.width / 2, self.videoPlayerView.superview.bounds.size.height / 2, 0, 0);
[self.videoPlayerView setCenter:CGPointMake( self.videoPlayerView.superview.bounds.size.width / 2, self.videoPlayerView.superview.bounds.size.height / 2)];
Expand All @@ -313,16 +331,27 @@ - (void)launchFullScreen
completion:nil];

self.videoPlayerView.frame = self.videoPlayerView.superview.bounds;
}


if (self.topView) {
self.topView.frame = CGRectMake(0, 0, self.videoPlayerView.frame.size.width, self.topView.frame.size.height);
}

if ([self.delegate respondsToSelector:@selector(setFullScreenToggled:)]) {
[self.delegate setFullScreenToggled:self.fullScreenModeToggled];
}
}];
}
else
{
if (self.topView) {
self.topView.frame = CGRectMake(0, 0, self.videoPlayerView.frame.size.width, self.topView.frame.size.height);
}

if ([self.delegate respondsToSelector:@selector(setFullScreenToggled:)]) {
[self.delegate setFullScreenToggled:self.fullScreenModeToggled];
}
}];

}
}
}

Expand All @@ -331,11 +360,11 @@ - (void)minimizeVideo
if (self.fullScreenModeToggled) {
self.fullScreenModeToggled = NO;
[self.videoPlayerView setFullscreen:NO];
[self hideControlsAnimated:NO];
[self syncFullScreenButton:self.interfaceOrientation];

if (self.topView) {
[self.containingViewController.view addSubview:self.topView];
[self.topView removeFromSuperview];
[self.videoPlayerView addSubview:self.topView];
}

if (self.isAlwaysFullscreen) {
Expand All @@ -353,6 +382,18 @@ - (void)minimizeVideo

[self.videoPlayerView removeFromSuperview];
}];
[[UIApplication sharedApplication].keyWindow.rootViewController dismissViewControllerAnimated:self.isAlwaysFullscreen completion:^{

if (!self.isAlwaysFullscreen) {
[self showControls];
}
[[UIApplication sharedApplication] setStatusBarHidden:NO
withAnimation:UIStatusBarAnimationFade];

if ([self.delegate respondsToSelector:@selector(setFullScreenToggled:)]) {
[self.delegate setFullScreenToggled:self.fullScreenModeToggled];
}
}];
} else {
[UIView animateWithDuration:0.45f
delay:0.0f
Expand All @@ -364,25 +405,17 @@ - (void)minimizeVideo
if (showShareOptions) {
[self presentShareOptions];
}
if (self.topView) {
self.topView.frame = CGRectMake(0, 0, self.videoPlayerView.frame.size.width, self.topView.frame.size.height);
}
}];

[self.videoPlayerView removeFromSuperview];
[self.containingViewController.view addSubview:self.videoPlayerView];
}


[[UIApplication sharedApplication].keyWindow.rootViewController dismissViewControllerAnimated:self.isAlwaysFullscreen completion:^{

if (!self.isAlwaysFullscreen) {
[self showControls];
}
[[UIApplication sharedApplication] setStatusBarHidden:NO
withAnimation:UIStatusBarAnimationFade];

if ([self.delegate respondsToSelector:@selector(setFullScreenToggled:)]) {
[self.delegate setFullScreenToggled:self.fullScreenModeToggled];
}
}];
if (self.topView) {
self.topView.frame = CGRectMake(0, 0, self.videoPlayerView.frame.size.width, self.topView.frame.size.height);
}
}
}

Expand Down
Binary file modified VideoPlayerKitSampleProject/.DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions VideoPlayerKitSampleProject/.bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
BUNDLE_DISABLE_SHARED_GEMS: "1"
BUNDLE_PATH: /Users/aserbin/Documents/Work/VideoPlayerKitMyGit/VideoPlayerKitSampleProject/cache
2 changes: 1 addition & 1 deletion VideoPlayerKitSampleProject/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ platform :ios, '5.0'

inhibit_all_warnings!

pod "VideoPlayerKit", :git => 'https://github.com/ign/VideoPlayerKit.git'
pod "VideoPlayerKit", :git => 'https://github.com/aserbin/VideoPlayerKit.git'
45 changes: 22 additions & 23 deletions VideoPlayerKitSampleProject/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
PODS:
- cocoa-oauth (0.0.1):
- NSData+Base64 (~> 1.0)
- Facebook-iOS-SDK (3.1.1)
- NSData+Base64 (1.0.0)
- REComposeViewController (0.0.1)
- ShareThis (1.0.0):
- cocoa-oauth (= 0.0.1)
- Facebook-iOS-SDK (= 3.1.1)
- REComposeViewController (= 0.0.1)
- VideoPlayerKit (1.0.0):
- ShareThis (= 1.0.0)

COCOAPODS: 0.16.1
DEPENDENCIES:
- VideoPlayerKit (from `https://github.com/aserbin/VideoPlayerKit.git`)

DEPENDENCIES:
- VideoPlayerKit (from `https://github.com/ign/VideoPlayerKit.git')
EXTERNAL SOURCES:
VideoPlayerKit:
:git: https://github.com/aserbin/VideoPlayerKit.git

PODS:
- Facebook-iOS-SDK (3.1.1)
- NSData+Base64 (1.0.0)
- REComposeViewController (0.0.1)
- ShareThis (1.0.0):
- Facebook-iOS-SDK (= 3.1.1)
- REComposeViewController (= 0.0.1)
- cocoa-oauth (= 0.0.1)
- VideoPlayerKit (1.0.0):
- ShareThis (= 1.0.0)
- cocoa-oauth (0.0.1):
- NSData+Base64 (~> 1.0)

SPEC CHECKSUMS:
NSData+Base64: 8b910cb8a64f45daec6fb15936c36a9a911c57ca
Facebook-iOS-SDK: 5fc068ebfd8c8c9b0fad476bc36dbbf1fffeebc8
SPEC CHECKSUMS:
cocoa-oauth: 8f4c8b77c77ac660de37f8125557c4ec09b0118a
Facebook-iOS-SDK: 5fc068ebfd8c8c9b0fad476bc36dbbf1fffeebc8
NSData+Base64: 36c4e5b6479259c1a68866ccd2a8dd385c9744f7
REComposeViewController: 346eb738a68ddcce77b3d771695a91c7af1a5701
ShareThis: 9df4a93ea65a676c9e852588d98d35e4831b7636
VideoPlayerKit: df22855ccb0a286e7b9c20a439ebd73b7c78d00c
VideoPlayerKit: 8fd3d6feb81303cf971426aff830c1e9a6984247

EXTERNAL SOURCES:
VideoPlayerKit:
:git: https://github.com/ign/VideoPlayerKit.git
COCOAPODS: 0.22.2
Loading