Skip to content

Commit

Permalink
修复旋转 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
bqlin committed May 3, 2016
1 parent 3cb219c commit 0f527db
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 48 deletions.
3 changes: 2 additions & 1 deletion polyvSDK/Base.lproj/Main.storyboard 100644 → 100755
Expand Up @@ -124,6 +124,7 @@
<scene sceneID="ctK-LQ-XsA">
<objects>
<tabBarController id="Ykz-V1-jlL" customClass="RootViewViewController" sceneMemberID="viewController">
<simulatedOrientationMetrics key="simulatedOrientationMetrics"/>
<tabBar key="tabBar" contentMode="scaleToFill" id="BaW-50-xnK">
<rect key="frame" x="0.0" y="0.0" width="320" height="49"/>
<autoresizingMask key="autoresizingMask"/>
Expand Down Expand Up @@ -176,7 +177,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="41" y="20"/>
<point key="canvasLocation" x="137" y="25"/>
</scene>
<!--Upload Demo View Controller-->
<scene sceneID="EqW-xP-oqB">
Expand Down
2 changes: 1 addition & 1 deletion polyvSDK/DetailViewController.m
Expand Up @@ -30,7 +30,7 @@ -(void)viewDidDisappear:(BOOL)animated {
}

-(void)viewWillAppear:(BOOL)animated{

[self.videoPlayer configObserver];
self.isPresented = NO;
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:NO];
Expand Down
63 changes: 24 additions & 39 deletions polyvSDK/DetailViewController2.m 100644 → 100755
Expand Up @@ -10,7 +10,6 @@
#import "SkinVideoViewController.h"
#import "PvVideo.h"
#import "PolyvSettings.h"
#import "PLVSlider.h"
@interface DetailViewController2 ()

@property (nonatomic, strong) SkinVideoViewController*videoPlayer;
Expand All @@ -30,7 +29,12 @@ -(void)movieLoadStateDidChange:(NSNotification *)notification{
}

-(void)viewDidDisappear:(BOOL)animated {
[self.videoPlayer pause];
self.isPresented = YES;
self.videoPlayer.contentURL = nil;
[self.videoPlayer stop];
[self.videoPlayer cancel];
[self.videoPlayer cancelObserver];
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super viewDidDisappear:animated];
}

Expand Down Expand Up @@ -60,7 +64,8 @@ - (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)butt
-(void)viewWillAppear:(BOOL)animated{
self.isPresented = NO;
[[UIApplication sharedApplication] setStatusBarHidden:NO];

[self.videoPlayer configObserver];

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
Expand All @@ -69,7 +74,6 @@ -(void)viewWillAppear:(BOOL)animated{
selector:@selector(movieLoadStateDidChange:)
name:MPMoviePlayerPlaybackStateDidChangeNotification
object:nil];
[super viewWillAppear:animated];
}


Expand All @@ -84,29 +88,23 @@ - (void)viewDidLoad {
}


[self.view addSubview:self.videoPlayer.view];
[self.videoPlayer setParentViewController:self];
//需要保留导航栏
[self.videoPlayer keepNavigationBar:YES];
[self.videoPlayer setHeadTitle:self.video.title];
//开启片头播放
//[self.videoPlayer enableTeaser:YES];
[self.videoPlayer setNavigationController:self.navigationController];
[self.videoPlayer setVid:self.video.vid];
// self.videoPlayer.contentURL = [NSURL URLWithString:@"http://hls.videocc.net/sl8da4jjbx/e/sl8da4jjbxe69c6942a7a737819660de_1.m3u8"];
[self.view addSubview:self.videoPlayer.view];
[self.videoPlayer setParentViewController:self];
//需要保留导航栏
[self.videoPlayer keepNavigationBar:YES];
[self.videoPlayer setHeadTitle:self.video.title];
//开启片头播放
//[self.videoPlayer enableTeaser:YES];
[self.videoPlayer setNavigationController:self.navigationController];
[self.videoPlayer setVid:self.video.vid];
[self.videoPlayer enableDanmu:YES];
//直接跳到上一次播放位置
//[self.videoPlayer setWatchStartTime:380];
[self.videoPlayer play];

// 问答开关
self.videoPlayer.enableExam = YES;

//直接跳到上一次播放位置
//[self.videoPlayer setWatchStartTime:380];
[self.videoPlayer play];
//UIImage*logo = [UIImage imageNamed:@"pvlogo.png"];

//[self.videoPlayer setLogo:logo location:PvLogoLocationTopLeft size:CGSizeMake(70,30) alpha:0.8];

self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPlay target:self action:@selector(nextVC)];



[self.videoPlayer setFullscreenBlock:^{
Expand All @@ -115,34 +113,21 @@ - (void)viewDidLoad {
[self.videoPlayer setShrinkscreenBlock:^{
// NSLog(@"show toolbox back if needed");
}];


//[self showConfirmationAlert];




[super viewDidLoad];
}

- (void)nextVC{
UIViewController *newVC = [[UIViewController alloc] init];
newVC.view.backgroundColor = [UIColor grayColor];
newVC.title = @"测试切换新控制器";
[self.navigationController pushViewController:newVC animated:YES];
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

- (void)dealloc{
self.isPresented = YES;
self.videoPlayer.contentURL = nil;
[self.videoPlayer stop];
[self.videoPlayer cancel];
[self.videoPlayer cancelObserver];
[[NSNotificationCenter defaultCenter] removeObserver:self];
}

/*
#pragma mark - Navigation
Expand Down
35 changes: 28 additions & 7 deletions polyvSDK/SkinVideoViewController.m
Expand Up @@ -168,19 +168,39 @@ - (instancetype)initWithFrame:(CGRect)frame
[self setFrame:frame];

// self.view.frame = frame;
[self resetIfNeed];
self.view.backgroundColor = [UIColor blackColor];
self.controlStyle = MPMovieControlStyleNone;
[self.view addSubview:self.videoControl];
self.videoControl.frame = self.view.bounds;
[self configControlAction];
self.videoControl.closeButton.hidden = YES;
self.watchVideoTimeDuration = 0;
self.originFrame = frame;
[self configObserver];
[self configControlAction];
// [self configObserver];
}
return self;
}

- (void)resetIfNeed{
if (_durationTimer) {
_durationTimer = nil;
}
if (_watchTimer) {
_watchTimer = nil;
}
if (_bufferTimer) {
_bufferTimer = nil;
}
if (_stallTimer) {
_stallTimer = nil;
}
if (self.videoControl) {
self.videoControl = nil;
}
self.watchVideoTimeDuration = 0;
}


#pragma mark - Override Method


Expand Down Expand Up @@ -302,6 +322,9 @@ - (void)configObserver
object:self];

[self addOrientationObserver];
// UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(panHandler:)];
// pan.delegate = self;
// [self.view addGestureRecognizer:pan];
}

-(void)videoInfoLoaded{
Expand Down Expand Up @@ -338,10 +361,6 @@ - (void)configControlAction
[self.videoControl.snapshotButton addTarget:self action:@selector(snapshot) forControlEvents:UIControlEventTouchUpInside];
[self setProgressSliderMaxMinValues];
[self monitorVideoPlayback];

UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(panHandler:)];
pan.delegate = self;
[self.view addGestureRecognizer:pan];
}

-(void)setVid:(NSString *)vid{
Expand Down Expand Up @@ -889,6 +908,7 @@ - (SkinVideoViewControllerView *)videoControl
{
if (!_videoControl) {
_videoControl = [[SkinVideoViewControllerView alloc] init];
_videoControl.translatesAutoresizingMaskIntoConstraints = YES;
}
return _videoControl;
}
Expand Down Expand Up @@ -1178,6 +1198,7 @@ - (void)shrinkScreenStyle{
}
}


@end


Expand Down

0 comments on commit 0f527db

Please sign in to comment.