JLChen
2021-02-01 7ab063d5c658143b5bce7ca8e5ae9bfc700bb1d8
EZSDK/EZSDK/EZSDK.m
@@ -20,11 +20,6 @@
#import "EZDeviceTableViewController.h"
#import "EZHCNetDeviceSDK.h"
#define CURR_LANG ([[NSLocale preferredLanguages] objectAtIndex:0])
#define LanguageIsChinese ([CURR_LANG rangeOfString:@"zh-Hans"].location != NSNotFound)
@implementation EZSDK
/**
@@ -35,8 +30,8 @@
{
    static BOOL isHavelibInit=NO;
    if (!isHavelibInit) {
//        isHavelibInit=YES;
        NSLog(@"第一次初始化萤石库");
        //        isHavelibInit=YES;
        //        NSLog(@"第一次初始化萤石库");
        if (!LanguageIsChinese) {
            //海外版
            isHavelibInit = [EZGlobalSDK initLibWithAppKey:globalAppKey];
@@ -53,6 +48,113 @@
    }
    return isHavelibInit;
}
/**
 设置SDK的accessToken
 */
+(void)setEZAccessToken:(NSString *) accessToken
{
    [[GlobalKit shareKit] setAccessToken:accessToken];
    [EZOPENSDK setAccessToken:accessToken];
}
//获取当前屏幕显示的viewcontroller   (这里面获取的相当于rootViewController)
+(UINavigationController *)getCurrentVC
{
    UIWindow * window = [[UIApplication sharedApplication] keyWindow];
    if (window.windowLevel != UIWindowLevelNormal)
    {
        NSArray *windows = [[UIApplication sharedApplication] windows];
        for(UIWindow * tmpWin in windows)
        {
            if (tmpWin.windowLevel == UIWindowLevelNormal)
            {
                window = tmpWin;
                break;
            }
        }
    }
    return  (UINavigationController *)window.rootViewController;
}
/**
 直接跳转到萤石摄像头列表
 */
+(void)go2EZvizMonitor
{
    //    NSLog(@"go2EZvizMonitor");
    //获取EZMain的stroyboard文件
    UIStoryboard *ezMainStoryboard = [UIStoryboard storyboardWithName:@"EZMain" bundle:nil];
    //获取EZMain.storyboard的实例ViewController--获取摄像头列表
    EZDeviceTableViewController *instanceVC = [ezMainStoryboard instantiateViewControllerWithIdentifier:@"EZCameraList"];
    //push摄像头列表的viewController
    [[self getCurrentVC] setNavigationBarHidden:NO];
    //        NSLog(@"willpush********");
    [[self getCurrentVC] pushViewController:instanceVC animated:YES];
    //        NSLog(@"had pushed********");
}
/**
 跳转添加添加设备
 */
+(void)addEzvizMonitor
{
    //    NSLog(@"添加摄像头");
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
        UIStoryboard *addDeviceStoryBoard = [UIStoryboard storyboardWithName:@"AddDevice" bundle:nil];
        EZAddByQRCodeViewController *rootViewController = [addDeviceStoryBoard instantiateViewControllerWithIdentifier:@"AddByQRCode"];
        [[self getCurrentVC] setNavigationBarHidden:NO];
        [[self getCurrentVC] pushViewController:rootViewController animated:YES];
    } else {
        //        [UIView dd_showMessage:@"iOS 7.0以下扫码功能请自行实现"];
        NSLog(@"iOS 7.0以下扫码功能请自行实现");
    }
}
/**
 查看视频监控直播
 */
+(void)Play:(NSObject*)deviceInfo
{
    UIStoryboard *addDeviceStoryBoard = [UIStoryboard storyboardWithName:@"EZMain" bundle:nil];
    EZLivePlayViewController *rootViewController = [addDeviceStoryBoard instantiateViewControllerWithIdentifier:@"EZLivePlayViewController"];
    //        NSLog(@"play--iphone--rootViewController");
    rootViewController.deviceInfo=(EZDeviceInfo *)deviceInfo;
    NSLog(@"play--iphone--deviceName -%@",rootViewController.deviceInfo.deviceName);
    //        rootViewController.cameraIndex=0;
    [[self getCurrentVC] setNavigationBarHidden:NO];
    [[self getCurrentVC] pushViewController:rootViewController animated:YES];
}
/**
 打开摄像头设置页面
 */
+(void)setting:(NSObject*)deviceInfo
{
    UIStoryboard *settingStoryBoard=[UIStoryboard storyboardWithName:@"EZMain" bundle:nil];
    EZSettingViewController *settingVC=[settingStoryBoard instantiateViewControllerWithIdentifier:@"EZSettingViewController"];
    settingVC.deviceInfo=(EZDeviceInfo *)deviceInfo;
    [[self getCurrentVC] setNavigationBarHidden:NO];
    [[self getCurrentVC] pushViewController:settingVC animated:YES];
}
/**
 回放播放历史
 */
+(void)playBackVideo:(NSObject*)deviceInfo
{
    UIStoryboard *playBackStoryBoard=[UIStoryboard storyboardWithName:@"EZMain" bundle:nil];
    EZPlaybackViewController *playBackVC=[playBackStoryBoard instantiateViewControllerWithIdentifier:@"EZPlaybackViewController"];
    playBackVC.deviceInfo=(EZDeviceInfo *)deviceInfo;
    [[self getCurrentVC] setNavigationBarHidden:NO];
    [[self getCurrentVC] pushViewController:playBackVC animated:YES];
}
//+(void)MonitorPushMessage:(NSString *)MonitorType ID:(NSString *)ID
//{
@@ -122,68 +224,6 @@
//    return ICommons;
//}
//获取当前屏幕显示的viewcontroller   (这里面获取的相当于rootViewController)
+(UINavigationController *)getCurrentVC
{
    UIWindow * window = [[UIApplication sharedApplication] keyWindow];
    if (window.windowLevel != UIWindowLevelNormal)
    {
        NSArray *windows = [[UIApplication sharedApplication] windows];
        for(UIWindow * tmpWin in windows)
        {
            if (tmpWin.windowLevel == UIWindowLevelNormal)
            {
                window = tmpWin;
                break;
            }
        }
    }
   return  (UINavigationController *)window.rootViewController;
}
//+(void)login
//{
//    if ([GlobalKit shareKit].accessToken)
//    {
//        [EZOPENSDK setAccessToken:[GlobalKit shareKit].accessToken];
//        NSLog(@"login---1");
//    }
//    else
//    {
//        [EZOPENSDK openLoginPage:^(EZAccessToken *accessToken) {
//            [[GlobalKit shareKit] setAccessToken:accessToken.accessToken];
//            [EZOPENSDK setAccessToken:accessToken.accessToken];
//            NSLog(@"login---2");
//        }];
//    }
//}
+(void)go2EZvizMonitor
{
        NSLog(@"go2EZvizMonitor");
//    if (isPad) {
//        //获取EZMain的stroyboard文件
//        UIStoryboard *ezMainStoryboard = [UIStoryboard storyboardWithName:@"EZMainForIPad" bundle:nil];
//        //获取EZMain.storyboard的实例ViewController--获取摄像头列表
//        EZDeviceTableViewController *instanceVC = [ezMainStoryboard instantiateViewControllerWithIdentifier:@"EZCameraList"];
//        //push摄像头列表的viewController
//        [[self getCurrentVC] setNavigationBarHidden:NO];
//        [[self getCurrentVC] pushViewController:instanceVC animated:YES];
//    }else{
        //获取EZMain的stroyboard文件
        UIStoryboard *ezMainStoryboard = [UIStoryboard storyboardWithName:@"EZMain" bundle:nil];
        //获取EZMain.storyboard的实例ViewController--获取摄像头列表
        EZDeviceTableViewController *instanceVC = [ezMainStoryboard instantiateViewControllerWithIdentifier:@"EZCameraList"];
        //push摄像头列表的viewController
        [[self getCurrentVC] setNavigationBarHidden:NO];
        NSLog(@"willpush********");
        [[self getCurrentVC] pushViewController:instanceVC animated:YES];
        NSLog(@"had pushed********");
//    }
}
//+(NSArray *)getDeviceList:(int)pageIndex :(int)pageSize
//{
@@ -221,87 +261,21 @@
//    return deviceListaArray  ;
//}
+(void)addEzvizMonitor
{
    NSLog(@"添加摄像头");
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
        UIStoryboard *addDeviceStoryBoard = [UIStoryboard storyboardWithName:@"AddDevice" bundle:nil];
        EZAddByQRCodeViewController *rootViewController = [addDeviceStoryBoard instantiateViewControllerWithIdentifier:@"AddByQRCode"];
        [[self getCurrentVC] setNavigationBarHidden:NO];
        [[self getCurrentVC] pushViewController:rootViewController animated:YES];
    } else {
//        [UIView dd_showMessage:@"iOS 7.0以下扫码功能请自行实现"];
        NSLog(@"iOS 7.0以下扫码功能请自行实现");
    }
}
+(void)Play:(NSObject*)deviceInfo
{
//    if (isPad) {
//        NSLog(@"play--ipad--");
//        UIStoryboard *addDeviceStoryBoard = [UIStoryboard storyboardWithName:@"EZMainForIPad" bundle:nil];
//        EZLivePlayViewController *rootViewController = [addDeviceStoryBoard instantiateViewControllerWithIdentifier:@"EZLivePlayViewController"];
//        rootViewController.deviceInfo=(EZDeviceInfo *)deviceInfo;
//        rootViewController.cameraIndex=0;
//        [[self getCurrentVC] setNavigationBarHidden:NO];
//        [[self getCurrentVC] pushViewController:rootViewController animated:YES];
//    }else{
        NSLog(@"play--iphone--1225");
        UIStoryboard *addDeviceStoryBoard = [UIStoryboard storyboardWithName:@"EZMain" bundle:nil];
        EZLivePlayViewController *rootViewController = [addDeviceStoryBoard instantiateViewControllerWithIdentifier:@"EZLivePlayViewController"];
        NSLog(@"play--iphone--rootViewController");
        rootViewController.deviceInfo=(EZDeviceInfo *)deviceInfo;
         NSLog(@"play--iphone--deviceName -%@",rootViewController.deviceInfo.deviceName);
//        rootViewController.cameraIndex=0;
        [[self getCurrentVC] setNavigationBarHidden:NO];
        [[self getCurrentVC] pushViewController:rootViewController animated:YES];
//+(void)login
//{
//    if ([GlobalKit shareKit].accessToken)
//    {
//        [EZOPENSDK setAccessToken:[GlobalKit shareKit].accessToken];
//        NSLog(@"login---1");
//    }
}
+(void)setting:(NSObject*)deviceInfo
{
//    if (isPad) {
//        UIStoryboard *settingStoryBoard=[UIStoryboard storyboardWithName:@"EZMainForIPad" bundle:nil];
//        EZSettingViewController *settingVC=[settingStoryBoard instantiateViewControllerWithIdentifier:@"EZSettingViewController"];
//        settingVC.deviceInfo=(EZDeviceInfo *)deviceInfo;
//        [[self getCurrentVC] setNavigationBarHidden:NO];
//        [[self getCurrentVC] pushViewController:settingVC animated:YES];
//    }else{
        UIStoryboard *settingStoryBoard=[UIStoryboard storyboardWithName:@"EZMain" bundle:nil];
        EZSettingViewController *settingVC=[settingStoryBoard instantiateViewControllerWithIdentifier:@"EZSettingViewController"];
        settingVC.deviceInfo=(EZDeviceInfo *)deviceInfo;
        [[self getCurrentVC] setNavigationBarHidden:NO];
        [[self getCurrentVC] pushViewController:settingVC animated:YES];
//    else
//    {
//        [EZOPENSDK openLoginPage:^(EZAccessToken *accessToken) {
//            [[GlobalKit shareKit] setAccessToken:accessToken.accessToken];
//            [EZOPENSDK setAccessToken:accessToken.accessToken];
//            NSLog(@"login---2");
//        }];
//    }
}
+(void)playBackVideo:(NSObject*)deviceInfo
{
//    if (isPad) {
//        UIStoryboard *playBackStoryBoard=[UIStoryboard storyboardWithName:@"EZMainForIPad" bundle:nil];
//        EZPlaybackViewController *playBackVC=[playBackStoryBoard instantiateViewControllerWithIdentifier:@"EZPlaybackViewController"];
//        playBackVC.deviceInfo=(EZDeviceInfo *)deviceInfo;
//        playBackVC.cameraIndex=0;
//        [[self getCurrentVC] setNavigationBarHidden:NO];
//        [[self getCurrentVC] pushViewController:playBackVC animated:YES];
//    }else{
        UIStoryboard *playBackStoryBoard=[UIStoryboard storyboardWithName:@"EZMain" bundle:nil];
        EZPlaybackViewController *playBackVC=[playBackStoryBoard instantiateViewControllerWithIdentifier:@"EZPlaybackViewController"];
        playBackVC.deviceInfo=(EZDeviceInfo *)deviceInfo;
//        playBackVC.cameraIndex=0;
        [[self getCurrentVC] setNavigationBarHidden:NO];
        [[self getCurrentVC] pushViewController:playBackVC animated:YES];
//    }
}
//}
@end