|
//
// TPMovieController.m
// ThePaperBase
//
// Created by zhousan on 15/12/11.
// Copyright © 2015年 scar1900. All rights reserved.
//
#import "TPMovieController.h"
@interface TPMovieController ()
@end
@implementation TPMovieController
- (instancetype)initWithFrame:(CGRect)frame {
self = [super init];
if (self) {
self.moviePlayer = [[ALMoviePlayerController alloc] initWithFrame:frame];
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self.view addSubview:self.moviePlayer.view];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarOrientationWillChange:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (BOOL)shouldAutorotate {
return YES;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAllButUpsideDown;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationPortrait | UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight;
}
- (void)statusBarOrientationWillChange:(NSNotification *)note {
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) {
orientation = UIInterfaceOrientationPortrait;
if (self.moviePlayer) {
[self.moviePlayer setFullscreen:NO animated:YES];
}
}else {
orientation = UIInterfaceOrientationLandscapeLeft;
if (self.moviePlayer) {
[self.moviePlayer setFullscreen:YES animated:YES];
}
}
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter]removeObserver:self];
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
|