Przeglądaj źródła

1.TV 投屏相关

huangxiaodong 1 rok temu
rodzic
commit
0ccc2ae5f0

+ 3 - 1
创维盒子/双子星云手机/AppDelegate/AppDelegate.h

@@ -9,7 +9,7 @@
 #import "cloudPhoneExtraFileListModel.h"
 #import "NASMsgModel.h"
 #import "couldPhoneBaseInfoModel.h"
-
+#import "TvStatusModel.h"
 
 @interface AppDelegate : UIResponder <UIApplicationDelegate>
 
@@ -25,6 +25,8 @@
 @property (nonatomic, assign)BOOL DisabledFileTransferType;//禁用文件传输
 @property (nonatomic, assign)BOOL isImageNewFor130;//1.3.0的镜像是否待更新
 @property (nonatomic, assign)BOOL isWebSockLinkOKAginType;//WebSock断开后或者链接上了
+@property (nonatomic, strong) TvStatusModel * TvStatusMod;
+
 
 @property (nonatomic, strong) NASMsgModel * NASMsgMod;
 @property (nonatomic, copy) NSString * NASShareFileService;//走公网的

+ 1 - 0
创维盒子/双子星云手机/CloudPlayer/Model/TvStatusModel.h

@@ -13,6 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic, copy) NSString* type;
 //@property (nonatomic, copy) NSString* status;
 @property (nonatomic, copy) NSString* sn;
+@property (nonatomic, assign) BOOL isTVShowType;//是否为TV投屏
 @end
 
 NS_ASSUME_NONNULL_END

+ 8 - 1
创维盒子/双子星云手机/CloudPlayer/Model/TvStatusModel.m

@@ -8,5 +8,12 @@
 #import "TvStatusModel.h"
 
 @implementation TvStatusModel
-
+- (BOOL)isTVShowType{
+    
+    if([self.msg containsString:@"PushStreamBActivity"]){
+        return  YES;
+    }
+    
+    return  NO;
+}
 @end

+ 35 - 4
创维盒子/双子星云手机/CloudPlayer/PlayerViewController.mm

@@ -1292,14 +1292,20 @@ NSDate *lastVideoTome;/*上一帧数据时间*/
                 break;
             case 100:
                 {
-                    NSString *commondStr  = @"{\"type\":\"wakeupTV\"}";
-                    [weakSelf send_data:commondStr];
+                    self->mPlayerView.controlBtn.userInteractionEnabled = NO;
+                    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+                        self->mPlayerView.controlBtn.userInteractionEnabled = YES;
+                    });
+                    [[webSocketManager shareInstance] onTvFun];
                 }
                 break;
             case 101:
                 {
-                    NSString *commondStr  = @"{\"type\":\"TvOff\"}";
-                    [weakSelf send_data:commondStr];
+                    self->mPlayerView.controlBtn.userInteractionEnabled = NO;
+                    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+                        self->mPlayerView.controlBtn.userInteractionEnabled = YES;
+                    });
+                    [weakSelf showCloseTVP2PFun];
                 }
                 break;
             default:
@@ -1355,6 +1361,31 @@ NSDate *lastVideoTome;/*上一帧数据时间*/
     [self.navigationController popViewControllerAnimated:YES];
 }
 
+#pragma mark 显示关闭投屏提示语
+- (void)showCloseTVP2PFun{
+    /*弹窗提示TV投屏*/
+    ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_close_TV_p2p_tip",nil)
+                                                                                     msg:nil
+                                                                                imageStr:nil
+                                                                             cancelTitle:NSLocalizedString(@"other_cancel",nil)
+                                                                                 okTitle:NSLocalizedString(@"my_set_TVP2P_Open_sure",nil) isOkBtnHighlight:YES
+                                                                              didClickOk:^{
+        [self gotoCloseTVP2PFun];
+    } didClickCancel:^{
+        //HLog(@"2222");
+        
+    }];
+    nextVC.modalPresentationStyle = UIModalPresentationCustom;
+    [self presentViewController:nextVC animated:YES completion:^{
+        nextVC.view.superview.backgroundColor = [UIColor clearColor];
+    }];
+}
+
+#pragma mark 确认开始TV投屏
+-(void)gotoCloseTVP2PFun
+{
+    [[webSocketManager shareInstance] offTvFun];
+}
 
 - (void)needToRebootFun
 {

+ 33 - 14
创维盒子/双子星云手机/CloudPlayer/View/playerSetView.m

@@ -11,6 +11,7 @@
 @interface playerSetView ()
 @property(nonatomic, strong) SYJUISwitch * bottomNavSwitch;//底部导航栏开关
 @property(nonatomic, strong) SYJUISwitch * fullScreenSwitch;//全面屏开关
+@property(nonatomic, strong) UIButton *TVButton;
 @end
 
 @implementation playerSetView
@@ -18,6 +19,9 @@
 - (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    self.backgroundColor = [UIColor hwColor:@"000000" alpha:0.6];
+    
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getCouldPhoneTvStatusFun:)  name:getCouldPhoneTvStatusNotification  object:nil];
+    
    [self drawAnyView];
    
    return self;
@@ -137,12 +141,12 @@
     }];
     
     
-    NSArray *titleArr = @[NSLocalizedString(@"cloudPhone_set_screenshot_tip",nil),
+    NSArray *titleArr = @[//NSLocalizedString(@"cloudPhone_set_screenshot_tip",nil),
                           NSLocalizedString(@"my_set_no_restart_phone",nil),
                           NSLocalizedString(@"cloudPhone_set_exit_tip",nil),
     ];
     
-    NSArray *imageArr = @[@"cloudPhone_set_screenshot",
+    NSArray *imageArr = @[//@"cloudPhone_set_screenshot",
                           @"cloudPhone_set_restart",
                           @"cloudPhone_set_exit",
     ];
@@ -151,13 +155,15 @@
     CGFloat imageWH = 24.0;
     
     CGFloat butHeight = imageWH +20 +5;
-    CGFloat butWidth = (245 -12*2)/3.0;  //70.0;
+    //CGFloat butWidth = (245 -12*2)/3.0;  //70.0;
+    CGFloat butWidth = (245 -12*2)/2.0;  //70.0;
     CGFloat butSpace = 0.0; //(245  - butWidth*3)/3.0;
     
     for (int i=0; i<titleArr.count; i++) {
         
         UIButton *but = [[UIButton alloc] init];
-        but.tag = 10+i;
+        //but.tag = 10+i;
+        but.tag = 11+i;
         [but addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
         [bg2View addSubview:but];
         //but.backgroundColor = [UIColor greenColor];
@@ -198,18 +204,21 @@
     }
     
     /**********************************************************************************/
-    UIButton *TVButton = [[UIButton alloc] init];
-    TVButton.tag = 100;
-    [TVButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
-    [TVButton setTitle:NSLocalizedString(@"my_set_no_TV_p2p",nil) forState:(UIControlStateNormal)];
-    [TVButton setTitle:NSLocalizedString(@"my_set_no_close_TV_p2p",nil) forState:(UIControlStateSelected)];
-    TVButton.layer.cornerRadius = 12;
-    [TVButton.titleLabel setFont:[UIFont boldSystemFontOfSize:14.f]];
-    TVButton.backgroundColor = [UIColor hwColor:@"#29313D"];
-    [blackBgView addSubview:TVButton];
+    _TVButton = [[UIButton alloc] init];
+    _TVButton.tag = 100;
+    [_TVButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
+    [_TVButton setTitle:NSLocalizedString(@"my_set_no_TV_p2p",nil) forState:(UIControlStateNormal)];
+    [_TVButton setTitle:NSLocalizedString(@"my_set_no_close_TV_p2p",nil) forState:(UIControlStateSelected)];
+    _TVButton.layer.cornerRadius = 12;
+    [_TVButton.titleLabel setFont:[UIFont boldSystemFontOfSize:14.f]];
+    _TVButton.backgroundColor = [UIColor hwColor:@"#29313D"];
+    [blackBgView addSubview:_TVButton];
    
+    if(ksharedAppDelegate.TvStatusMod.isTVShowType){
+        _TVButton.selected = YES;
+    }
   
-    [TVButton mas_makeConstraints:^(MASConstraintMaker *make) {
+    [_TVButton mas_makeConstraints:^(MASConstraintMaker *make) {
         make.height.mas_equalTo(50);
         make.left.mas_equalTo(12);
         make.right.mas_equalTo(-12);
@@ -254,4 +263,14 @@
 {
     [self removeFromSuperview];
 }
+
+- (void)getCouldPhoneTvStatusFun:(NSNotification*)not
+{
+    if(ksharedAppDelegate.TvStatusMod.isTVShowType){
+        _TVButton.selected = YES;
+    }
+    else{
+        _TVButton.selected = NO;
+    }
+}
 @end

+ 4 - 0
创维盒子/双子星云手机/cloudPhone/cloudPhoneViewController.m

@@ -193,6 +193,10 @@
         {
             PlayerViewController *vc = [PlayerViewController new];
             [self pushViewController:vc animated:YES];
+            
+            if(ksharedAppDelegate.TvStatusMod.isTVShowType){
+                [[iToast makeText:NSLocalizedString(@"tv_p2p_ing",nil)] show];
+            }
         }
             break;
             

+ 6 - 0
创维盒子/双子星云手机/cloudPhone/websocket/webSocketManager.h

@@ -84,6 +84,12 @@ NS_ASSUME_NONNULL_BEGIN
 
 #pragma mark 云机截图保存到云机图库
 - (void)screenshotInCloudPhoneFun;
+#pragma mark 获取TV投屏状态
+- (void)getTvStatusFun;
+#pragma mark 关闭TV投屏状态
+- (void)offTvFun;
+#pragma mark 开启TV投屏状态
+- (void)onTvFun;
 
 //上传
 - (void)beginGotoUploadFileFunBy:(uploadFileDataModel *)uploadFileDataMod;

+ 40 - 6
创维盒子/双子星云手机/cloudPhone/websocket/webSocketManager.m

@@ -294,6 +294,16 @@ static webSocketManager *webSocketManagerInstance = nil;
             else if ([messageType isEqualToString:@"TvStatus"]){/*获取TV投屏信息*/
                 [weakSelf getCouldPhoneTvStatusResponseFun:dataDict];
             }
+            else if ([messageType isEqualToString:@"TvOff"]){/*关闭TV投屏*/
+                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+                    [weakSelf getTvStatusFun];
+                });
+            }
+            else if ([messageType isEqualToString:@"wakeupTV"]){/*开启TV投屏*/
+                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+                    [weakSelf getTvStatusFun];
+                });
+            }
             else if ([messageType isEqualToString:@"reboot"]){/*重启*/
                 [weakSelf stopForceStartTimerFun];
             }
@@ -475,6 +485,8 @@ static webSocketManager *webSocketManagerInstance = nil;
     [self getExtraFilesListFun];
     
     [self getBaseInfoFun];
+    
+    [self getTvStatusFun];
 }
 
 #pragma mark 盒子第一次连接成功  给ws发送信息 单点登录 把其他账号挤下去
@@ -739,14 +751,15 @@ static webSocketManager *webSocketManagerInstance = nil;
 - (void)getCouldPhoneTvStatusResponseFun:(NSDictionary *)dataDict
 {
     TvStatusModel *model = [[TvStatusModel alloc] initWithDictionary:dataDict error:nil];
-    [[NSNotificationCenter defaultCenter] postNotificationName:getCouldPhoneTvStatusNotification object:model];
+    ksharedAppDelegate.TvStatusMod = model;
     
-    if(![model.msg containsString:@"PushStreamBActivity"])
-    {
-        return;
-    }
+    [[NSNotificationCenter defaultCenter] postNotificationName:getCouldPhoneTvStatusNotification object:model];
     
-    HLog(@"hxd  待处理")
+//    if(![model.msg containsString:@"PushStreamBActivity"])
+//    {
+//        return;
+//    }
+//    
 //    UIViewController*topVc = self.navigationController.viewControllers.lastObject;
 //    if([topVc isKindOfClass:[PlayerViewController class]]){
 //        [[iToast makeText:NSLocalizedString(@"tv_p2p_ing",nil)] show];
@@ -894,4 +907,25 @@ static webSocketManager *webSocketManagerInstance = nil;
     [self send_data:commondStr];
 }
 
+#pragma mark 获取TV投屏状态
+- (void)getTvStatusFun
+{
+    NSString *commondStr  = @"{\"type\":\"TvStatus\"}";
+    [self send_data:commondStr];
+}
+
+#pragma mark 关闭TV投屏状态
+- (void)offTvFun
+{
+    NSString *commondStr  = @"{\"type\":\"TvOff\"}";
+    [self send_data:commondStr];
+}
+
+#pragma mark 开启TV投屏状态
+- (void)onTvFun
+{
+    NSString *commondStr  = @"{\"type\":\"wakeupTV\"}";
+    [self send_data:commondStr];
+}
+
 @end