重庆迈尖科技有限公司
2019-01-30 94217b294ccd75a34787eb04d6e273e99536e45b
BuWanVideo2.0/XYRDetailViewController.m
@@ -46,12 +46,12 @@
#import "GDTMobBannerView.h"
//优酷播放器
#import "YTEngineOpenViewManager.h"
#import "YYMediaPlayerEvents.h"
//#import "YTEngineOpenViewManager.h"
//#import "YYMediaPlayerEvents.h"
//PPTV播放器导入
#import "PPTVview.h"
#import <PPTVSdk/PPTVSdk.h>
//#import "PPTVview.h"
//#import <PPTVSdk/PPTVSdk.h>
#import "LGLAlertView.h"
@@ -64,7 +64,7 @@
#define BETWEEN_BOUND_FULL 100
#define BETWEEN_BOUND_NORMAL 20
@interface XYRDetailViewController ()<CMuneBarDelegate,UIScrollViewDelegate,UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,YYMediaPlayerEvents,UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate,YTHNetDelegateRecommend,UIGestureRecognizerDelegate,YTHBacktoApplicationsDelegate,GDTNativeAdDelegate,GDTMobBannerViewDelegate,HXEasyCustomShareViewDelegate>{
@interface XYRDetailViewController ()<CMuneBarDelegate,UIScrollViewDelegate,UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate,YTHNetDelegateRecommend,UIGestureRecognizerDelegate,YTHBacktoApplicationsDelegate,GDTNativeAdDelegate,GDTMobBannerViewDelegate,HXEasyCustomShareViewDelegate>{
    int _gather;//集数加载更多的控制变量,默认为1
    int isCollectNum;//当前选中的集
    
@@ -97,7 +97,7 @@
@property (weak, nonatomic) IBOutlet UIButton *playBtn;//播放按钮
@property (weak, nonatomic) IBOutlet UIButton *backBtn;//详情页面的返回按钮
@property (weak, nonatomic) IBOutlet UIImageView *image;//顶部视频图片
@property (weak, nonatomic) IBOutlet YYAnimatedImageView *image;//顶部视频图片
@property (weak, nonatomic) IBOutlet UILabel *detailTitle;//顶部的标题
@property (weak, nonatomic) IBOutlet UILabel *detailTitleBackgroundColor;//顶部标题背景
@property (weak, nonatomic) IBOutlet UIButton *backgroundButton;//覆盖在头图片的Button,响应播放事件
@@ -120,14 +120,14 @@
@property (nonatomic,strong) NSArray *PeopleSeeVideo;//获取到的大家都在看的数据
//优酷的三个属性:
@property (nonatomic, retain) YTEngineOpenViewManager *viewManager;
@property (nonatomic, strong) YYMediaPlayer *cloudPlayer;
//@property (nonatomic, retain) YTEngineOpenViewManager *viewManager;
//@property (nonatomic, strong) YYMediaPlayer *cloudPlayer;
@property (nonatomic, retain) UIButton *backButton;
@property (nonatomic, retain) UITextView *textView;
@property (nonatomic, assign) BOOL YKloadSuccess;    //优酷创建成功
//PPTV
@property (nonatomic, strong) PPTVview *pptvview;
//@property (nonatomic, strong) PPTVview *pptvview;
@property (nonatomic, assign) BOOL isPPTVSuccess;     //PPTV创建成功
@property (nonatomic, strong) UIButton *collectionbt; //外部收藏按钮
@property (nonatomic, strong) NSString *showurl;      //PPTV来源
@@ -137,7 +137,7 @@
@end
@implementation XYRDetailViewController
@synthesize player = _player;
//@synthesize player = _player;
@synthesize islocal;
@synthesize videoItem;
@@ -149,6 +149,14 @@
    ApplicationDelegate.YNetdelegateRecommend = self;
    //实现出去应用或者回到应用的处理
    ApplicationDelegate.YBackAppDelegate = self;
    if (KIsiPhoneX) {
//        self.topLayout.constant = 20;
        self.backLayout.constant = 39;
    }else{
//        self.topLayout.constant = 0;
        self.backLayout.constant = 19;
    }
    //加载基础数据
    [self loadData];
    //视频名称背景色
@@ -198,6 +206,7 @@
 */
- (IBAction)backToMainViewController:(id)sender {
    [self backToRootView];
}
@@ -212,29 +221,40 @@
 *  @param sender 收藏按钮
 */
- (void)ClickCollection:(UIButton *)sender {
    if (sender.isSelected) {
        [sender setSelected:NO];
        [[YTHNetInterface startInterface] getScoreCollectWithUid:[YTHsharedManger startManger].Uid withId:self.Model.Id withThirdType:self.Model.ThirdType WithType:@"0" withSystem:@"1" withBlock:^(BOOL isSuccessful, id result, NSString *error) {
            if (isSuccessful) {
                if([self.NewResource intValue]==16){
                    [_pptvview SuccessCollection:NO]; //通知PPTV播放器收藏
    if([[NSUserDefaults standardUserDefaults] boolForKey:@"userOnLine"]){
        if (sender.isSelected) {
            [sender setSelected:NO];
            [[YTHNetInterface startInterface] getScoreCollectWithUid:[YTHsharedManger startManger].Uid withId:self.Model.Id withThirdType:self.Model.ThirdType WithType:@"0" withSystem:@"1" withBlock:^(BOOL isSuccessful, id result, NSString *error) {
                if (isSuccessful) {
                    if([self.NewResource intValue]==16){
                        //                    [_pptvview SuccessCollection:NO]; //通知PPTV播放器收藏
                    }
                }else{//取消收藏失败
                    [sender setSelected:YES];
                }
            }else{//取消收藏失败
                [sender setSelected:YES];
            }
        }];
            }];
        }else{
            [sender setSelected:YES];
            [[YTHNetInterface startInterface] getScoreCollectWithUid:[YTHsharedManger startManger].Uid withId:self.Model.Id withThirdType:self.Model.ThirdType WithType:@"1" withSystem:@"1" withBlock:^(BOOL isSuccessful, id result, NSString *error) {
                if (isSuccessful) {
                    if([self.NewResource intValue]==16){
                        //                    [_pptvview SuccessCollection:YES];  //通知PPTV播放器收藏
                    }
                }else{//收藏失败
                    [sender setSelected:NO];
                }
            }];
        }
    }else{
        [sender setSelected:YES];
        [[YTHNetInterface startInterface] getScoreCollectWithUid:[YTHsharedManger startManger].Uid withId:self.Model.Id withThirdType:self.Model.ThirdType WithType:@"1" withSystem:@"1" withBlock:^(BOOL isSuccessful, id result, NSString *error) {
            if (isSuccessful) {
                if([self.NewResource intValue]==16){
                    [_pptvview SuccessCollection:YES];  //通知PPTV播放器收藏
                }
            }else{//收藏失败
                [sender setSelected:NO];
            }
        //未登录,引导用户登录
        LoggingViewController *loginVC=[[LoggingViewController alloc] init];
        loginVC.ispresent=YES;
        [self presentViewController:loginVC animated:YES completion:^{
        }];
    }
}
@@ -431,7 +451,7 @@
    NSMutableArray *arr=[[NSMutableArray alloc] initWithCapacity:(_DetailModel.Data.ResourceList.count+5)];
    NSArray *ResourceList=[[NSMutableArray alloc] initWithArray:_DetailModel.Data.ResourceList];
    for (int i=0; i<_DetailModel.Data.ResourceList.count; i++) {
        arr[i]=[ResourceList[i] objectForKey:@"Name"];
        arr[i]=[ResourceList[i] objectForKey:@"Picture"];
        if ([[ResourceList[i] objectForKey:@"Checked"] intValue]==1) {
            self.NewResource=[ResourceList[i] objectForKey:@"Id"];
            //交换数组元素,让默认的播放源放在第一个
@@ -453,7 +473,7 @@
        [_MuneBar setUserInteractionEnabled:YES];
        _MuneBar.delegate = self;
        _MuneBar.center = CGPointMake(((KScreenW/3)-80)/2, 22);
        [self.collectionView bringSubviewToFront:_MuneBar];
//        [self.collectionView reloadSections:[NSIndexSet indexSetWithIndex:0]];
        [self.collectionView reloadData];
@@ -461,9 +481,10 @@
}
//默认网络情况
- (void)NetWorkStuas{
    switch ([YTHsharedManger startManger].NetworkStatus) {
        case 0:{//当前网络不可用
            UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示"message:@"当前网络不可用,是否连接网络?"preferredStyle:UIAlertControllerStyleAlert];
            UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示"message:@"当前网络不可用,是否使用连接网络?"preferredStyle:UIAlertControllerStyleAlert];
            //取消
            [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
                [self backToRootView];
@@ -472,8 +493,8 @@
                }];
            }]];
            //去连接网络
            [alert addAction:[UIAlertAction actionWithTitle:@"连接免费网络" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=WIFI"]];
            [alert addAction:[UIAlertAction actionWithTitle:@"连接网络" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                [[UIApplication sharedApplication]openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] ];
                [alert dismissViewControllerAnimated:YES completion:^{
                    
                }];
@@ -484,19 +505,22 @@
        }
            break;
        case 1:{//移动网络
            UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"警告"message:@"当前网络为付费网络!"preferredStyle:UIAlertControllerStyleAlert];
            static BOOL isFirst = YES;
            if (!isFirst) {
                return;
            }else{
                isFirst = NO;
            }
            UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"温馨提示"message:@"您目前没有连接WIFi,是否使用流量继续观看" preferredStyle:UIAlertControllerStyleAlert];
            //继续观看
            [alert addAction:[UIAlertAction actionWithTitle:@"继续观看" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            [alert addAction:[UIAlertAction actionWithTitle:@"继续" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                [alert dismissViewControllerAnimated:YES completion:^{
                    
                }];
            }]];
            //去连接网络
            [alert addAction:[UIAlertAction actionWithTitle:@"连接免费网络" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=WIFI"]];
                [alert dismissViewControllerAnimated:YES completion:^{
                }];
            [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            }]];
            [self presentViewController:alert animated:YES completion:^{
                
@@ -540,13 +564,13 @@
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
#endif
{
    if(_isPPTVSuccess){   //如果是PPTV 播放  返回可旋转
        if(_pptvview.playoptions.isHalfScreen){
            return UIInterfaceOrientationMaskLandscape;
        }else{
            return UIInterfaceOrientationMaskPortrait;
        }
    }
//    if(_isPPTVSuccess){   //如果是PPTV 播放  返回可旋转
//        if(_pptvview.playoptions.isHalfScreen){
//            return UIInterfaceOrientationMaskLandscape;
//        }else{
//            return UIInterfaceOrientationMaskPortrait;
//        }
//    }
    if (self.YKloadSuccess==YES) {  //如果加载了优酷播放器
        return UIInterfaceOrientationMaskAllButUpsideDown;
    }
@@ -631,8 +655,6 @@
        [Share shareAPP:self];
}
/**
 *  点击关注或取消关注
 */
@@ -699,7 +721,9 @@
    NSDate *date = [NSDate date];
    NSTimeInterval seconds = [date timeIntervalSinceDate:self.startTime];
    NSLog(@"%f",seconds);
    if (seconds < 1.5) {
    static BOOL bor = NO;
    if (seconds < 1.5 && bor) {
        bor = YES;
        return;
    }
    self.startTime = date;
@@ -738,111 +762,6 @@
    }
}
/********************PPTV**************************/
-(void)playPPTV:(NSString*)urlstring{
    [self PPTVclear];
    NSString *qudao = @"2462";  //渠道号
    NSInteger sdkType = 0;
    sdkType |= DLNA_DMC;        //sdk内部播放器
    NSString *parmString = [NSString stringWithFormat:@"tunnel=%@&sdkType=%zd",qudao,sdkType];
    _isPPTVSuccess = [[PPTVSdk sharedPPTVSdk] initializeWithUrl:nil params:parmString logPath:nil];
    //进行初始化 返回值是否成功
    if(_isPPTVSuccess){
        [SVProgressHUD show];
        _pptvview = [[PPTVview alloc]init];
        _pptvview.viewcontroller = self;
        _pptvview.Brightness = [UIScreen mainScreen].brightness;
        NSInteger sdkType = 0;
        sdkType |= DLNA_DMC;        //sdk内部播放器
        //播放器内部片源类型
        int VedioType;
        if(self.DetailModel.Data.ShowType==1){//综艺
            VedioType = 1;
        }else{//非综艺
            VedioType = 2;
        }
        //是否收藏
        BOOL Iscollection;
        if(_collectionbt.isSelected){
            Iscollection = YES;
        }else{
            Iscollection = NO;
        }
        //隐藏控件
        [_image bringSubviewToFront:self.view];
        _image.userInteractionEnabled = YES;
        _backBtn.tag = 113;
        [_pptvview initWithSid:nil WithUrl:urlstring WithVid:nil WithHisPlayTime:0 WithPlayerType:PLAYER_TYPE_VOD WithViewController:self WithFatherView:self.view WithFatherFrameView:_image WithTitleStr:_Model.Name WihtChosSet:isCollectNum-1  WithDataArray:_VideoDetailList WithType:VedioType WithIsCllection:Iscollection WithImage:self.image.image WithShowUrl:_showurl];
        __weak typeof (self) selfweak = self;
        _pptvview.clearpptv = ^(){
            selfweak.isPPTVSuccess = NO;
            selfweak.image.userInteractionEnabled = NO;
            selfweak.backgroundButton.hidden = NO;
            selfweak.detailTitle.hidden = NO;
        };
        _pptvview.next = ^(){
            if (selfweak.DetailModel.Data.ShowType==1) {   //是综艺
                if (selfweak.VideoDetailList.count>6*_gather && isCollectNum > 6*_gather) {
                    _gather++;
//                    [selfweak.collectionView reloadSections:[NSIndexSet indexSetWithIndex:1]];
                    [self.collectionView reloadData];
                }
            }else{  //不是综艺
                if (selfweak.VideoDetailList.count>10*_gather && isCollectNum >= 10*_gather) {
                    _gather++;
//                    [selfweak.collectionView reloadSections:[NSIndexSet indexSetWithIndex:1]];
                    [self.collectionView reloadData];
                }
            }
            if(isCollectNum < selfweak.VideoDetailList.count){
                isCollectNum += 1;
                NSArray *arr = [selfweak.collectionView indexPathsForVisibleItems];
                NSIndexPath * targetIndex;
                NSIndexPath * lastIndex;
                for( int i = 0 ; i < arr.count ; ++i){
                    NSIndexPath * temp = arr[i];
                    if(isCollectNum-1 == temp.row ){
                        targetIndex = temp;
                    }else if(isCollectNum -2 == temp.row){
                        lastIndex = temp;
                    }
                }
//                [selfweak.collectionView reloadItemsAtIndexPaths:@[targetIndex,lastIndex]];
                [_collectionView reloadData];
                [selfweak PPTVplay:[NSString stringWithFormat:@"%d",isCollectNum-1] WithBoolInit:selfweak.isPPTVSuccess];
            }
            return isCollectNum-1;
        };
        _pptvview.Collectioning = ^(){  //全屏收藏点击
            [selfweak ClickCollection:selfweak.collectionbt];
        };
        _pptvview.rload = ^(){
            dispatch_async(dispatch_get_main_queue(), ^{
                [selfweak.collectionView reloadData];
            });
        };
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(selfchose:) name:@"selfchose" object:nil];
        [_pptvview initPlayInfo];
    }
    //控件隐藏处理
    _backgroundButton.hidden = YES;
    _detailTitle.hidden = YES;
    _backBtn.hidden = NO;
    [_backBtn bringSubviewToFront:self.view];
    _playBtn.hidden = YES;
}
-(void)selfchose:(NSNotification*)notification{
    NSDictionary* num = [notification userInfo];
    isCollectNum = ((NSNumber*)[num objectForKey:@"index"]).intValue +1;
@@ -861,20 +780,20 @@
}
//在已有的PPTV播放器进行播放
-(void)playPPTVSecend:(NSString*)urlstring{
    [SVProgressHUD show];
    [_pptvview playvedio:urlstring];
    [_pptvview.playoptions.collection OtherChose:isCollectNum-1];   //播放器内部显示同步
}
//-(void)playPPTVSecend:(NSString*)urlstring{
//    [SVProgressHUD show];
//    [_pptvview playvedio:urlstring];
//    [_pptvview.playoptions.collection OtherChose:isCollectNum-1];   //播放器内部显示同步
//}
//PPTV退出亲清除
-(void)PPTVclear{
    if(!_pptvview){
        return ;
    }
    [_pptvview clear];
}
////PPTV退出亲清除
//-(void)PPTVclear{
//    if(!_pptvview){
//        return ;
//    }
//    [_pptvview clear];
//}
//PPTV获取数据
@@ -898,9 +817,9 @@
            
            //加载PPTV播放器
            if(!BL){  //没有被初始化过
                [self playPPTV:urlstring];
//                [self playPPTV:urlstring];
            }else{
                [self playPPTVSecend:urlstring];
//                [self playPPTVSecend:urlstring];
            }
        }else{
            NSLog(@"获取视频播放链接失败%@",error);
@@ -920,7 +839,10 @@
    [SVProgressHUD showWithStatus:@"精彩,马上就来!"];
    [_playBtn setEnabled:NO];
    [_backgroundButton setEnabled:NO];
    Videodetaillist *lst=self.VideoDetailList[[IDS intValue]];
    Videodetaillist *lst;
    if ([IDS intValue] <= self.VideoDetailList.count) {
        lst=self.VideoDetailList[[IDS intValue]];
    }
    [[YTHNetInterface startInterface] getparseVideoUrlWithUid:[YTHsharedManger startManger].Uid WithId:[(NSDictionary *)lst objectForKey:@"Id"] WithVideoId:self.DetailModel.Data.Id WithSystem:@"1" WithType:[(NSDictionary *)lst objectForKey:@"Type"] WithResourceId:_NewResource WithEID:nil withBlock:^(BOOL isSuccessful, id result, NSString *error) {
        if (isSuccessful) {
            NSLog(@"获取视频播放链接成功");
@@ -974,7 +896,7 @@
                [_backgroundButton setEnabled:YES];
                if([_NewResource intValue]==15){
                    //加载优酷播放器
                    [self loadYKPlayer:urlstring];
//                    [self loadYKPlayer:urlstring];
                }
            }else{//站外播放
                NSString *urlstring=[[dictionaryDta objectForKey:@"Data"] objectForKey:@"Url"];
@@ -994,76 +916,76 @@
 *
 *  @param urlstring 播放地址
 */
-(void)loadYKPlayer:(NSString *)urlstring{
    if(_cloudPlayer==nil){
        [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
        _cloudPlayer = [[YYMediaPlayer alloc] init];
        _cloudPlayer.controller = self;
        _cloudPlayer.view.clipsToBounds = YES;
        _cloudPlayer.fullscreen = NO;
        _cloudPlayer.platform = @"youku";
        CGSize size = self.view.bounds.size;
        CGFloat width = 0.f;
        if (DEVICE_TYPE_IPAD) {
            width = 681.f;
        } else {
            width = KScreenWp;
        }
        CGFloat height = width * 9.0f / 16.0f;
        _cloudPlayer.view.frame = CGRectMake(0, 0, width, height);
        _playerFrame = CGRectMake(0, 20, size.width, size.height - 20);
        _cloudPlayerFrame = _cloudPlayer.view.frame;
        //竖屏时露出状态栏
        if ([[UIDevice currentDevice].systemVersion floatValue] >= 7){
            CGRect bounds = self.view.frame;
            self.view.bounds = bounds;
        }
        self.MarkToTop.constant=8.0f;
        [self.view addSubview:_cloudPlayer.view];
        [self initViews];
        [_cloudPlayer addEventsObserver:self];
        _cloudPlayer.clientId = YKCLIENTId;
        _cloudPlayer.clientSecret = YKCLIENTSECRET;
        // 初始化播放器界面管理器
        _viewManager = [[YTEngineOpenViewManager alloc] initWithPlayer:_cloudPlayer];
        [_cloudPlayer addEventsObserver:_viewManager];
        [self.view bringSubviewToFront:self.backBtn];
        self.YKloadSuccess=YES;
    }
    if (!islocal) {
        [_cloudPlayer playVid:urlstring quality:kYYVideoQualityFLV password:nil from:0];
    } else {
        if (self.videoItem) {
            [_cloudPlayer playVideo:(id<YYMediaPlayerItem>)self.videoItem quality:kYYVideoQualityFLV from:0 oldEncrypt:NO];
        }
    }
}
//-(void)loadYKPlayer:(NSString *)urlstring{
//    if(_cloudPlayer==nil){
//        [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
//
//        _cloudPlayer = [[YYMediaPlayer alloc] init];
//        _cloudPlayer.controller = self;
//        _cloudPlayer.view.clipsToBounds = YES;
//        _cloudPlayer.fullscreen = NO;
//        _cloudPlayer.platform = @"youku";
//
//        CGSize size = self.view.bounds.size;
//
//        CGFloat width = 0.f;
//        if (DEVICE_TYPE_IPAD) {
//            width = 681.f;
//        } else {
//            width = KScreenWp;
//        }
//
//        CGFloat height = width * 9.0f / 16.0f;
//        _cloudPlayer.view.frame = CGRectMake(0, 0, width, height);
//
//        _playerFrame = CGRectMake(0, 20, size.width, size.height - 20);
//        _cloudPlayerFrame = _cloudPlayer.view.frame;
//
//        //竖屏时露出状态栏
//        if ([[UIDevice currentDevice].systemVersion floatValue] >= 7){
//            CGRect bounds = self.view.frame;
//            self.view.bounds = bounds;
//        }
//
//        self.MarkToTop.constant=8.0f;
//        [self.view addSubview:_cloudPlayer.view];
//
//        [self initViews];
//
//        [_cloudPlayer addEventsObserver:self];
//
//        _cloudPlayer.clientId = YKCLIENTId;
//        _cloudPlayer.clientSecret = YKCLIENTSECRET;
//
//        // 初始化播放器界面管理器
//        _viewManager = [[YTEngineOpenViewManager alloc] initWithPlayer:_cloudPlayer];
//        [_cloudPlayer addEventsObserver:_viewManager];
//        [self.view bringSubviewToFront:self.backBtn];
//        self.YKloadSuccess=YES;
//    }
//    if (!islocal) {
//        [_cloudPlayer playVid:urlstring quality:kYYVideoQualityFLV password:nil from:0];
//    } else {
//        if (self.videoItem) {
//            [_cloudPlayer playVideo:(id<YYMediaPlayerItem>)self.videoItem quality:kYYVideoQualityFLV from:0 oldEncrypt:NO];
//        }
//    }
//}
- (void)layout:(BOOL)fullscreen{
    CGFloat backHeight = _backButton.bounds.size.height;
    CGFloat y = 0;
    
    if (!fullscreen) {
        _cloudPlayer.view.frame = _cloudPlayerFrame;
//        _cloudPlayer.view.frame = _cloudPlayerFrame;
        y = (44 - backHeight) / 2;
        _backButton.frame = CGRectMake(MARGIN, y , BACK_WIDTH, backHeight);
    } else {
        _cloudPlayer.view.frame = self.view.frame;
//        _cloudPlayer.view.frame = self.view.frame;
        y = (30 - backHeight) / 2 + 20;
        _backButton.frame = CGRectMake(MARGIN, y, BACK_WIDTH, _backButton.bounds.size.height);
    }
    _textView.frame = CGRectMake(_cloudPlayer.view.center.x - TEXTVIEW_WIDTH/2, _cloudPlayer.view.center.y - TEXTVIEW_HEIGHT/2, TEXTVIEW_WIDTH, TEXTVIEW_HEIGHT);
//    _textView.frame = CGRectMake(_cloudPlayer.view.center.x - TEXTVIEW_WIDTH/2, _cloudPlayer.view.center.y - TEXTVIEW_HEIGHT/2, TEXTVIEW_WIDTH, TEXTVIEW_HEIGHT);
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orien{
@@ -1093,9 +1015,9 @@
    _textView.font = [UIFont systemFontOfSize:TEXTVIEW_FONT];
    _textView.editable = NO;
    _textView.userInteractionEnabled = NO;
    _textView.frame = CGRectMake(_cloudPlayer.view.center.x - TEXTVIEW_WIDTH/2,_cloudPlayer.view.center.y - TEXTVIEW_HEIGHT/2, TEXTVIEW_WIDTH, TEXTVIEW_HEIGHT);
//    _textView.frame = CGRectMake(_cloudPlayer.view.center.x - TEXTVIEW_WIDTH/2,_cloudPlayer.view.center.y - TEXTVIEW_HEIGHT/2, TEXTVIEW_WIDTH, TEXTVIEW_HEIGHT);
    [_textView setTextAlignment:NSTextAlignmentCenter];
    [_cloudPlayer.view addSubview:_textView];
//    [_cloudPlayer.view addSubview:_textView];
}
/**
@@ -1128,11 +1050,11 @@
    if (!DEVICE_TYPE_IPAD) {
        if (orien == UIInterfaceOrientationPortrait &&
            self.interfaceOrientation != orien) {
            [_cloudPlayer setFullscreen:NO];
//            [_cloudPlayer setFullscreen:NO];
        } else if (UIInterfaceOrientationIsLandscape(orien)) {
            UIInterfaceOrientation corien = self.interfaceOrientation;
            if (!UIInterfaceOrientationIsLandscape(corien)) {
                [_cloudPlayer setFullscreen:YES];
//                [_cloudPlayer setFullscreen:YES];
            }
        }
    }
@@ -1172,53 +1094,53 @@
/**
 *  优酷播放器方法
 */
- (void)endPlayCode:(YYErrorCode)err{
    NSString *tip;
    switch (err) {
        case YYPlayCompleted:
            tip = @"该视频已播放完成,点击重新播放";
            _textView.text = tip;
            break;
        case YYPlayCanceled:
            break;
        case YYErrorClientFormat:
            tip = [NSString stringWithFormat:@"client参数格式错误,错误码:%ld", (long)err];
            _textView.text = tip;
            break;
        case YYErrorInvalidClient:
            tip = [NSString stringWithFormat:@"client无效或sdk版本过低,错误码:%ld", (long)err];
            _textView.text = tip;
            break;
        case YYErrorPermissionDeny:
            tip = [NSString stringWithFormat:@"视频无权限播放,错误码:%ld", (long)err];
            _textView.text = tip;
            break;
        case YYErrorInitOpenView:
            tip = [NSString stringWithFormat:@"初始化界面无效,错误码:%ld", (long)err];
            _textView.text = tip;
            break;
        case YYDataSourceError:
            tip = [NSString stringWithFormat:@"媒体文件错误,错误码:%ld", (long)err];
            _textView.text = tip;
            break;
        case YYNetworkError:
            tip = [NSString stringWithFormat:@"网络连接超时,错误码:%ld, 点击重试", (long)err];
            _textView.text = tip;
            break;
        default:
            tip = [NSString stringWithFormat:@"播放发生错误,错误码:%ld, 点击重试", (long)err];
            _textView.text = tip;
            break;
    }
}
//- (void)endPlayCode:(YYErrorCode)err{
//    NSString *tip;
//    switch (err) {
//        case YYPlayCompleted:
//            tip = @"该视频已播放完成,点击重新播放";
//            _textView.text = tip;
//            break;
//        case YYPlayCanceled:
//            break;
//        case YYErrorClientFormat:
//            tip = [NSString stringWithFormat:@"client参数格式错误,错误码:%ld", (long)err];
//            _textView.text = tip;
//            break;
//        case YYErrorInvalidClient:
//            tip = [NSString stringWithFormat:@"client无效或sdk版本过低,错误码:%ld", (long)err];
//            _textView.text = tip;
//            break;
//        case YYErrorPermissionDeny:
//            tip = [NSString stringWithFormat:@"视频无权限播放,错误码:%ld", (long)err];
//            _textView.text = tip;
//            break;
//        case YYErrorInitOpenView:
//            tip = [NSString stringWithFormat:@"初始化界面无效,错误码:%ld", (long)err];
//            _textView.text = tip;
//            break;
//        case YYDataSourceError:
//            tip = [NSString stringWithFormat:@"媒体文件错误,错误码:%ld", (long)err];
//            _textView.text = tip;
//            break;
//        case YYNetworkError:
//            tip = [NSString stringWithFormat:@"网络连接超时,错误码:%ld, 点击重试", (long)err];
//            _textView.text = tip;
//            break;
//        default:
//            tip = [NSString stringWithFormat:@"播放发生错误,错误码:%ld, 点击重试", (long)err];
//            _textView.text = tip;
//            break;
//    }
//}
/**
 *  优酷播放器方法
 */
- (void)startPlay {
    if (_viewManager) {
        _textView.hidden = YES;
    }
}
//- (void)startPlay {
//    if (_viewManager) {
//        _textView.hidden = YES;
//    }
//}
- (void)setNewOrientation:(BOOL)fullscreen
{
@@ -1267,20 +1189,23 @@
 *  退出详情页面的方法
 */
-(void)backToRootView{
    if(_isPPTVSuccess){
        if(_pptvview.playoptions.isHalfScreen){
            [_pptvview FullScreen];
            return;
        }
        [self PPTVclear];
    }
//    if(_isPPTVSuccess){
//        if(_pptvview.playoptions.isHalfScreen){
//            [_pptvview FullScreen];
//            return;
//        }
//        [self PPTVclear];
//    }
//
    [SVProgressHUD dismiss];
    [self.player removeEventsObserver:_viewManager];
    [self dismissViewControllerAnimated:YES completion:^{
        [self.player stop];
        [self.player deinit];
    }];
    self.collectionView.delegate = nil;
    self.collectionView.dataSource = nil;
    [self.collectionView removeFromSuperview];
    self.collectionView = nil;
    _nativeAd.controller = nil;
    _nativeAd.delegate = nil;
//    [self.player removeEventsObserver:_viewManager];
    [self dismissViewControllerAnimated:YES completion:nil];
    //显示状态栏
    [[UIApplication sharedApplication] setStatusBarHidden:NO];
}
@@ -1312,6 +1237,7 @@
    //提示数据加载
    [SVProgressHUD showWithStatus:@"加载中"];
    [[YTHNetInterface startInterface] getVoideoDetailWithUid:[YTHsharedManger startManger].Uid  withLoginUid:[[NSUserDefaults standardUserDefaults] objectForKey:@"LoginUid"] withId:movieid withThirdType:thirdtype withSystem:@"1" WithResourceId:resourceId withBlock:^(BOOL isSuccessful, id result, NSString *error) {
        NSLog(@"%@",result);
        if (isSuccessful) {
            //瀑布流滑动到顶部
            [self.collectionView setContentOffset:CGPointMake(0, 0) animated:YES];
@@ -1347,8 +1273,7 @@
            _VideoDetailList=self.DetailModel.Data.VideoDetailList;
            //计算cell的大小
            [self CalculateHeightWithArray:_VideoDetailList];
            //加载视频源
            [self loadResourceItem];
            //加载广告
            [self loadAd];
            //加载相关视频
@@ -1359,12 +1284,16 @@
            [self getPeopleSeeVideowithVideoId:movieid];
            //加载评论视图
            [self reloadCommentView];
            //加载视频源
            [self loadResourceItem];
            //数据加载成功
            [SVProgressHUD dismiss];
        }else{
            NSLog(@"%@",error);
            //提示用户错误
            [SVProgressHUD showErrorWithStatus:@"加载失败!"];
            [SVProgressHUD dismiss];
//            [SVProgressHUD showErrorWithStatus:@"加载失败!"];
            
        }
    }];
@@ -1376,7 +1305,7 @@
-(void)SourcesSwitching:(NSInteger)index{
    [SVProgressHUD showWithStatus:@"视频源切换中"];
    if(_isPPTVSuccess){
        [self PPTVclear];
//        [self PPTVclear];
    }
    [[YTHNetInterface startInterface] getVoideoDetailWithUid:[YTHsharedManger startManger].Uid withLoginUid:[[NSUserDefaults standardUserDefaults] objectForKey:@"LoginUid"] withId:self.Model.Id withThirdType:self.Model.ThirdType withSystem:@"1" WithResourceId:_NewResource withBlock:^(BOOL isSuccessful, id result, NSString *error) {
        if (isSuccessful) {
@@ -1390,10 +1319,10 @@
            
            //需要考虑到正在播放优酷视屏时,如果切换爱奇艺的情况
            if([_NewResource intValue]!=15){
                [self.player.view removeFromSuperview];
                [self.player removeEventsObserver:_viewManager];
                [self.player stop];
                [self.player deinit];
//                [self.player.view removeFromSuperview];
//                [self.player removeEventsObserver:_viewManager];
//                [self.player stop];
//                [self.player deinit];
                
                //取消隐藏playBtn
                [_playBtn setHidden:NO];
@@ -1423,14 +1352,16 @@
 *  联网检查是否收藏
 */
-(void)checkWhetherCollection{
    [[YTHNetInterface startInterface] getIsCollectedWithUid:[YTHsharedManger startManger].Uid withId:self.Model.Id withThirdType:self.Model.ThirdType withSystem:@"1" withBlock:^(BOOL isSuccessful, id result, NSString *error) {
        UIButton *B1=[self.view viewWithTag:321];
        if (isSuccessful) {
            [B1 setSelected:YES];
        }else{
            [B1 setSelected:NO];
        }
    }];
//    if([[NSUserDefaults standardUserDefaults] boolForKey:@"userOnLine"]){
        [[YTHNetInterface startInterface] getIsCollectedWithUid:[YTHsharedManger startManger].Uid withId:self.Model.Id withThirdType:self.Model.ThirdType withSystem:@"1" withBlock:^(BOOL isSuccessful, id result, NSString *error) {
            UIButton *B1=[self.view viewWithTag:321];
            if (isSuccessful) {
                [B1 setSelected:YES];
            }else{
                [B1 setSelected:NO];
            }
        }];
//    }
}
//用于计算选集cell的大小
@@ -1571,9 +1502,7 @@
        //如果用户未登录
        LoggingViewController *loginVC=[[LoggingViewController alloc] init];
        loginVC.ispresent=YES;
        [self presentViewController:loginVC animated:YES completion:^{
        }];
        [self presentViewController:loginVC animated:YES completion:nil];
    }
}
@@ -1646,9 +1575,7 @@
            //如果用户未登录
            LoggingViewController *loginVC=[[LoggingViewController alloc] init];
            loginVC.ispresent=YES;
            [self presentViewController:loginVC animated:YES completion:^{
            }];
            [self presentViewController:loginVC animated:YES completion:nil];
        }
    }
}
@@ -1664,46 +1591,6 @@
        [self SourcesSwitching:index];
    }
    [self.MuneBar hideItems];
}
-(void)muneBarShow{
    UIButton *B1=[self.view viewWithTag:321];
    UIButton *B2=[self.view viewWithTag:322];
    UILabel *L1=[self.view viewWithTag:331];
    UILabel *L2=[self.view viewWithTag:332];
    if (B1.alpha == 1) {
        static BOOL isfirst;
        if(!isfirst){
            isfirst = YES;
            B1.transform = CGAffineTransformMakeScale(1.0f, 1.0f);
            B2.transform = CGAffineTransformMakeScale(1.0f, 1.0f);
            L1.transform = CGAffineTransformMakeScale(1.0f, 1.0f);
            L2.transform = CGAffineTransformMakeScale(1.0f, 1.0f);
        }
        [UIView beginAnimations:nil context:UIGraphicsGetCurrentContext()];
        [UIView setAnimationDuration:0.5];
        B1.transform=CGAffineTransformMakeScale(0.01f, 0.01f);
        B2.transform=CGAffineTransformMakeScale(0.01f, 0.01f);
        L1.transform=CGAffineTransformMakeScale(0.01f, 0.01f);
        L2.transform=CGAffineTransformMakeScale(0.01f, 0.01f);
        B1.alpha=0;
        [UIView commitAnimations];
    }else{
        [UIView beginAnimations:nil context:UIGraphicsGetCurrentContext()];
        [UIView setAnimationDuration:0.5];
        B1.transform=CGAffineTransformMakeScale(1.0f, 1.0f);
        B2.transform=CGAffineTransformMakeScale(1.0f, 1.0f);
        L1.transform=CGAffineTransformMakeScale(1.0f, 1.0f);
        L2.transform=CGAffineTransformMakeScale(1.0f, 1.0f);
        B1.alpha=1;
        [UIView commitAnimations];
    }
}
//尽管没有用,但是必须要写,不然muneBarShow方法不会走
-(void)muneBarHide{
}
#pragma mark - UIScrollViewDelegate
@@ -1762,12 +1649,12 @@
        }
        isCollectNum=(int)indexPath.row +1;
        if(lastIndex.row == 0 || indexPath.row == 0 || !lastIndex){ //在iphone6以上刷新row==0时无效的特殊处理
//            [_collectionView reloadSections:[NSIndexSet indexSetWithIndex:1]];
            [self.collectionView reloadData];
            [_collectionView reloadSections:[NSIndexSet indexSetWithIndex:1]];
//            [self.collectionView reloadData];
        }else{
//            [_collectionView reloadItemsAtIndexPaths:indexPatharr];
            [_collectionView reloadData];
            [_collectionView reloadItemsAtIndexPaths:indexPatharr];
//            [_collectionView reloadData];
        }
        
@@ -1784,15 +1671,15 @@
        
    }else{
        if(_isPPTVSuccess){   //清空pptv进行转换
            [self PPTVclear];
//            [self PPTVclear];
            _isPPTVSuccess = NO;
        }
        
        //考虑到正在播放优酷视频,切换到爱奇艺资源,所以要做一次移除优酷播放器的操作
        [self.player.view removeFromSuperview];
        [self.player removeEventsObserver:_viewManager];
        [self.player stop];
        [self.player deinit];
//        [self.player.view removeFromSuperview];
//        [self.player removeEventsObserver:_viewManager];
//        [self.player stop];
//        [self.player deinit];
        //取消隐藏playBtn
        [_playBtn setHidden:NO];
        [_backgroundButton setEnabled:NO];
@@ -1976,10 +1863,7 @@
        case 0:{
            if (kind == UICollectionElementKindSectionHeader){
                titleCollectionReusableView *titleCollectionReusableView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"titleCollectionReusableViewID" forIndexPath:indexPath];
                //加载视频源视图
                if (_MuneBar!=nil) {
                    [titleCollectionReusableView.resourceSelectionView addSubview:self.MuneBar];
                }
                //添加收藏的点击事件
                [titleCollectionReusableView.collectionBtn addTarget:self action:@selector(ClickCollection:) forControlEvents:UIControlEventTouchUpInside];
                _collectionbt = titleCollectionReusableView.collectionBtn;
@@ -1987,6 +1871,10 @@
                [titleCollectionReusableView.shareBtn addTarget:self action:@selector(clickShareButton:) forControlEvents:UIControlEventTouchUpInside];
                //联网检查是否收藏
                [self checkWhetherCollection];
                //加载视频源视图
                if (_MuneBar!=nil) {
                    [titleCollectionReusableView.resourceSelectionView addSubview:self.MuneBar];
                }
                
                return titleCollectionReusableView;
            }else if(kind == UICollectionElementKindSectionFooter){
@@ -2308,9 +2196,11 @@
 *  0 . 不可用   1. 移动网络   2.wifi   3.当前网络未知
 */
- (void)updateNet:(NSInteger )status{
    switch (status) {
        case 0:{//当前网络不可用
            UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示"message:@"当前网络不可用,是否连接网络?"preferredStyle:UIAlertControllerStyleAlert];
            UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"温馨提示"message:@"当前网络不可用,是否连接网络?"preferredStyle:UIAlertControllerStyleAlert];
            //取消
            [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
                [alert dismissViewControllerAnimated:YES completion:^{
@@ -2318,8 +2208,12 @@
                }];
            }]];
            //去连接网络
            [alert addAction:[UIAlertAction actionWithTitle:@"连接免费网络" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=WIFI"]];
            [alert addAction:[UIAlertAction actionWithTitle:@"连接网络" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                if (IOS_VERSION <  8.0) {
                }else{
                    [[UIApplication sharedApplication]openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
                }
                [alert dismissViewControllerAnimated:YES completion:^{
                    
                }];
@@ -2330,19 +2224,16 @@
        }
            break;
        case 1:{//移动网络
            UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"警告"message:@"当前网络为付费网络!"preferredStyle:UIAlertControllerStyleAlert];
            UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"温馨提示"message:@"您目前没有连接WIFi,是否使用流量继续观看"preferredStyle:UIAlertControllerStyleAlert];
            //继续观看
            [alert addAction:[UIAlertAction actionWithTitle:@"继续观看" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            [alert addAction:[UIAlertAction actionWithTitle:@"继续" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                [alert dismissViewControllerAnimated:YES completion:^{
                    
                }];
            }]];
            //去连接网络
            [alert addAction:[UIAlertAction actionWithTitle:@"连接免费网络" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=WIFI"]];
                [alert dismissViewControllerAnimated:YES completion:^{
                }];
            [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            }]];
            [self presentViewController:alert animated:YES completion:^{
                
@@ -2353,7 +2244,7 @@
            
            break;
        case 3:{//当前网络无法检测,需要用户自行判断网络
            UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示"message:@"无法监测当前网络,请自行判断网络!"preferredStyle:UIAlertControllerStyleAlert];
            UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"温馨提示"message:@"无法监测当前网络,请自行判断网络!"preferredStyle:UIAlertControllerStyleAlert];
            //继续观看
            [alert addAction:[UIAlertAction actionWithTitle:@"继续观看" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
                [alert dismissViewControllerAnimated:YES completion:^{
@@ -2377,17 +2268,17 @@
#pragma mark -YTHBacktoApplicationsDelegate
- (void)OutApplication{
    if (self.cloudPlayer) {
        [self.cloudPlayer pause];
    }
}
- (void)backApplication{
    if (self.cloudPlayer) {
        [self.cloudPlayer play];
    }
}
//- (void)OutApplication{
//    if (self.cloudPlayer) {
//        [self.cloudPlayer pause];
//    }
//}
//
//- (void)backApplication{
//    if (self.cloudPlayer) {
//        [self.cloudPlayer play];
//    }
//}
- (UIViewController *)viewControllerForPresentingModalView{
    return self;
@@ -2473,5 +2364,10 @@
    }];
}
- (void)dealloc {
}
@end