摄像机SDK

说明

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

SDK配置

配置环境

绿米环境:
framework:
LMCameraFramework.framework
LMMeshDriverFramework.framework
LMMeshDriver_UI.framework
LMSDKDeviceRouter.framework
LMCommonUI.framework
LMCommonUISwift.framework
LMFramework.framework
CameraP2PSDK.framework
CameraThirdFramework.framework
CameraSoundTouch.framework
CameraMiSodium.framework
CameraMiMP4V2.framework
CameraFaad.framework
bundle:
LMCameraFramework.bundle
LMCommonUI.bundle
LMCommonUISwift.bundle
LMFramework.bundle
LMSDKDeviceRouter.bundle

如下:

系统环境:

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

Pod 环境

Pod 集成方式及第三方依赖请参见环境搭建中的完整 Podfile。摄像机相关需至少集成以下 Aqara SDK:

pod 'LMCameraFramework'
pod 'CameraP2PSDK'
pod 'CameraThirdFramework'
pod 'CameraSoundTouch'
pod 'CameraMiSodium'
pod 'CameraMiMP4V2'
pod 'CameraFaad'
pod 'LMSDKDeviceRouter'

如下:

至此,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初始化

SDK 统一初始化方式请参见环境搭建。摄像机品类在初始化完成后,还需配置全屏播放回调(见下文「摄像机播放全屏播放配置」)。

跳转摄像机播放页

导入头文件:

#import <LMSDKDeviceRouter/LMSDKDeviceRouter.h>

import LMSDKDeviceRouter

使用 LMSDKDeviceRouter 跳转设备控制页,框架会自动识别摄像机设备并路由至播放页。详细用法参见设备控制SDK使用

Objective-C 示例:

[LMSDKDeviceRouter pushToDeviceControlPageWithDevice:device
                                navigationController:self.navigationController
                                            animated:YES
                                          completion:^(NSError * _Nullable error, id _Nullable result) {
}];

Swift 示例:

LMSDKDeviceRouter.pushToDeviceControlPage(with: device,
                                          navigationController: self.navigationController,
                                          animated: true) { error, result in
}

参数说明

参数 说明
device 设备信息对象(LMDevice,配网成功后从云端获取)
navigationController 当前导航控制器
animated 是否使用动画
completion 跳转完成回调

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

设置多语言:

导入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;
    }
}
  1. 在 SDK 初始化时配置 LMCameraOpenSDKGlobal 全屏回调:

导入头文件 #import <LMCameraFramework/LMCameraOpenSDKGlobal.h>

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

Objective-C 示例:

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

Swift 示例:

LMCameraOpenSDKGlobal.cameraPlayerFullScreenSettingCallBack { settings in
    if let delegate = UIApplication.shared.delegate as? AppDelegate {
        delegate.allowRotation = settings["allowRotation"] as? Int ?? 0
        let _ = delegate.application(UIApplication.shared, supportedInterfaceOrientationsFor: settings["window"] as? UIWindow)
    }
}

该方法会在播放页点击全屏时回调,请在 SDK 初始化阶段调用。

lumi LogoCopyright © 2023 深圳绿米联创科技有限公司 all right reserved,powered by Gitbook文档修改时间: 2026-08-26 16:55:47

results matching ""

    No results matching ""