摄像机SDK

说明

支持iOS最低系统 11.0; 仅支持arm64的系统环境; IDE环境:Xcode >= 14.0; 语言:Object-C;

SDK配置

配置环境

绿米环境:
framework:
LMCameraFramework.framework
LMMeshDriverFramework.framework
CameraP2PSDK.framework
LMMeshDriver_UI.framework
LMCommonUI.framework
LMFramework.framework
bundle:
LMCameraFramework.bundle
LMCommonUI.bundle
LMFramework.bundle

如下:

系统环境:

VideoToolbox AudioToolbox libz.tbd Libbz2.tbd Libiconv.tbd libc++.tbd Libc.tbd 如下:

Pod 环境:
  pod 'SVProgressHUD', '2.2.5'
  pod 'Masonry'
  pod 'TTTAttributedLabel'
  pod 'SDWebImage', '5.3.0'
  pod 'YYModel'
  pod 'MJRefresh'
  pod 'KVOController'
  pod 'JTCalendar', '~> 2.0'
  pod 'AFNetworking', '3.2.0'
  pod 'RealReachability', '~> 1.3.0'
  pod 'AWSS3', '~> 2.8.0'
  pod 'CocoaLumberjack'
  pod 'SSZipArchive'
  pod 'lottie-ios', '~> 2.5.3'
  pod 'UITableView+FDTemplateLayoutCell', '1.6'
  pod 'SCIndexView', '2.2.3'
  pod 'ReactiveObjC', '~> 3.1.0'
  pod 'FMDB'

如下:

至此,Aqara摄像机相关环境配置完成。

相关权限

Privacy - Photo Library Usage Description - 当您需要使用与图片或视频上传或存储相关的功能时,App需要使用您的相册权限用于访问相册、保存相片、视频

Privacy - Local Network Usage Description - 当需要查找、连接和控制本地网络上的设备时,App需要使用本地网络权限

Privacy - Microphone Usage Description - 当您使用视频对讲等功能时,App需要使用您的麦克风权限

Privacy - Camera Usage Description - 当您使用扫描二维码、添加头像、拍摄识别设备等功能时,App需要打开相机权限

App Transport Security Settings Allow Arbitrary Loads - YES

设置SDK内H5资源路径

参数 说明
h5UrlPrefix 日志以及其他H5相关功能需要使用
    + (void)setH5UrlPrefix:(NSString *)h5UrlPrefix;

示例:

    [LMOpenSDK setH5UrlPrefix:@"https://cdn.aqara.com/cdn/app/mainland/test-h5/index.html#"];

读取本地资源包

    [LMDriverConfig sharedInstance].isLocalResource(YES);

SDK使用

SDK初始化:

导入LMFramework #import <LMFramework/LMFramework.h> 初始化LMOpenSDK

参数 说明
host Aqara配网域名(见开放平台)
appId 从开放平台申请的APPID
appKey 与APPID配套的APPKey
iconBaseUrl 配网UI层部分CDN图片的路径
    [LMOpenSDK setServer:@""
                   appId:@“”
                  appKey:@“”
             iconBaseUrl:@""];

设置userInf

参数 说明
userId 用户ID
token 用户的token
    [LMOpenSDK setUserId:@“”
                   token:@“”];

跳转摄像机播放页:

导入 LMCameraOpenSDKGlobal.h #import <LMCameraFramework/LMCameraOpenSDKGlobal.h> 跳转摄像机播放页:

参数 说明
cameraEntity 构建的摄像机信息实体
navigationController 当前推出的navigationController
LMCameraDeviceEntity *cameraEntity = [[LMCameraDeviceEntity alloc] init];
cameraEntity.deviceId = @“”;
cameraEntity.deviceName = @“”;
cameraEntity.deviceModel = @“”;
[LMCameraOpenSDKGlobal pushLMCameraViewControllerWithCameraEntity:cameraEntity navigationController:self.navigationController animated:YES];

到这里,参数如果都正确的话就,已经能看到摄像机的直播画面了。

设置多语言:

导入LMFramework #import <LMFramework/LMFramework.h>

languageString 说明
zh-Hans 中文
en 英文
ru 俄文
ko 韩文
zh-HK 繁体
zh-Hant-TW 台湾-繁体
[LMOpenSDK setLanguage:languageString];

状态栏颜色配置:

状态栏的颜色配置需要宿主app的配合

1.需要首先在info.plist中设置View controller-based status bar appearance为YES

2.如果是UINavigaitonController,则需要添加一个继承自UINavigationController的子类,在子类中设置如下代码,使用子类来控制。或者添加UINavigaitonController的Category,在Category中重写如下代码:

- (UIStatusBarStyle)preferredStatusBarStyle {
    return [self.topViewController preferredStatusBarStyle];
}

- (UIViewController *)childViewControllerForStatusBarStyle {
    return self.topViewController;
}

摄像机播放全屏播放配置:

摄像机的全屏播放配置需要宿主app的配合

1.在Appdelegate.h中 声明 allowRotation属性

@property (nonatomic, assign) NSInteger allowRotation;

并在AppDelegate.m中重写函数:

- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window

并按以下代码实现该函数:

- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    if (_allowRotation == 1) {
        return UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft;
    } else if (_allowRotation == 2) {
        return UIInterfaceOrientationMaskLandscapeLeft;
    } else if (_allowRotation == 3) {
        return UIInterfaceOrientationMaskLandscapeRight;
    } else {
        return UIInterfaceOrientationMaskPortrait;
    }
}

2.实现LMCameraOpenSDKGlobal中的

参数 说明
cameraFullModeSettingCallBack 全屏设置回调
+ (void)setCameraFullModeSettingCallBack:(void(^ _Nonnull)(NSDictionary * _Nonnull cameraFullModeSettingDict))cameraFullModeSettingCallBack;

并按以下代码实现

[LMCameraOpenSDKGlobal cameraPlayerFullScreenSettingCallBack:^(NSDictionary * _Nonnull cameraFullModeSettingDict) {
        AppDelegate *appdelegate= (AppDelegate *)[UIApplication sharedApplication].delegate;
        appdelegate.allowRotation = [cameraFullModeSettingDict[@"allowRotation"] integerValue];
        [appdelegate application:[UIApplication sharedApplication] supportedInterfaceOrientationsForWindow:cameraFullModeSettingDict[@"window"]];
    }];

该方法会在播放页点击全屏的时候回调,请在适当的位置调用

Copyright © 2023 深圳绿米联创科技有限公司 all right reserved,powered by Gitbook文档修改时间: 2024-02-21 09:55:50

results matching ""

    No results matching ""