Last Updated on : 2024-06-17 07:53:42download
The video footage attached to video messages is encrypted. The API methods of ThingSmartCameraKit
and ThingSmartCameraMessageMediaPlayer
must be called to implement the video playback.
API description
- (UIView<ThingSmartVideoViewType> *)videoView;
API description
- (void)playMessage:(ThingSmartCameraMessageModel *)messageModel attachmentType:(ThingCameraMessageAttachmentType)attachmentType success:(void(^)(void))success failure:(void(^)(int errCode))failure finished:(void(^)(int errCode))onFinish;
Parameters
Parameter | Description |
---|---|
messageModel | The alert data model. |
attachmentType | The type of attached playback content. An alert might be a video message or audio message. |
success | The success callback. |
failure | The failure callback. |
onFinish | The callback that is executed when video playback is finished. errCode indicates an error message and 0 indicates that playback is finished. |
API description
- (void)playMessageAttachment:(NSString *)attachmentPath type:(ThingCameraMessageAttachmentType)attachmentType success:(void(^)(void))success failure:(void(^)(int errCode))failure finished:(void(^)(int errCode))onFinish;
Parameters
Parameter | Description |
---|---|
attachmentPath | The URL of the attached content. |
attachmentType | The type of attached audio or video content. The component ThingEncryptImage must be used to display attached images. |
success | The success callback. |
failure | The failure callback. |
onFinish | The callback that is executed when video playback is finished. errCode indicates an error message and 0 indicates that playback is finished. |
API description
- (int)pausePlay:(ThingCameraMessageAttachmentType)attachmentType;
API description
- (int)resumePlay:(ThingCameraMessageAttachmentType)attachmentType;
API description
- (void)stopPlay:(ThingCameraMessageAttachmentType)attachmentType;
API description
- (void)enableMute:(BOOL)mute success:(void(^)(void))success failure:(void (^)(NSError * error))failure;
Parameters
Parameter | Description |
---|---|
mute | Specifies whether to mute the video. |
success | The success callback. |
failure | The failure callback. |
Return values
Type | Description |
---|---|
int | An error message is returned or a value of 0 indicates a successful request. |
ThingSmartCameraMessageMediaPlayerDelegate
is the delegate protocol of the message player.
API description
- (void)mediaPlayer:(ThingSmartCameraMessageMediaPlayer *)player didReceivedFrame:(CMSampleBufferRef)frameBuffer videoFrameInfo:(ThingSmartVideoFrameInfo)frameInfo;
Parameters
Parameter | Description |
---|---|
player | The player object. |
frameBuffer | The YUV data of video frames. |
frameInfo | The information about video frame headers. |
frameInfo.nDuration | The total duration of video footage. |
frameInfo.nProgress | The progress of the current video frames. |
API description
- (void)mediaPlayer:(ThingSmartCameraMessageMediaPlayer *)player didReceivedAudioFrameInfo:(ThingSmartAudioFrameInfo)frameInfo;
Parameters
Parameter | Description |
---|---|
player | The player. |
frameInfo | The information about audio frame headers. |
frameInfo.nDuration | The total duration of audio content. |
frameInfo.nProgress | The progress of the current audio frames. |
For SDK versions earlier than v3.20.0, an API method of ThingSmartCloudManager
is called to implement playback of attached content. This API method is deprecated in v3.20.0. We recommend that you update to the latest SDK version at the earliest opportunity.
By default, alerts are generated independently from playback of SD card-stored content. During SD card-stored video recording, alerts and video footage can be simultaneously generated by the same triggers. Specifically, they have the following differences:
The switch for SD card-stored video recording is set independently from the switch for detection alerts. Therefore, during SD card-stored video recording, alerts do not always trigger video recording.
In certain cases, alerts can be linked with video footage stored on the SD card. The IPC SDK does not provide a typical API method to query video footage based on this type of correlation. However, to find the video footage triggered by alerts, users can find the time and date when the alerts were generated. Then, check whether the target video footage was created on this date. You can implement navigation from alerts to playback of SD card-stored video footage in this way.
- (void)enableDetect {
if ([self.dpManager isSupportDP:ThingSmartCameraMotionDetectDPName]) {
bool motionDetectOn = [[self.dpManager valueForDP:ThingSmartCameraMotionDetectDPName] tysdk_toBool];
if (!motionDetectOn) {
[self.dpManager setValue:@(YES) forDP:ThingSmartCameraMotionDetectDPName
success:^(id result) {
// Motion detection is enabled.
} failure:^(NSError *error) {
// A network error.
}];
}
[self.dpManager setValue:ThingSmartCameraMotionHigh
forDP:ThingSmartCameraMotionSensitivityDPName
success:^(id result) {
// The sensitivity of motion detection is set to high sensitivity.
} failure:^(NSError *error) {
// A network error.
}];
}
}
- (void)viewDidLoad {
[super viewDidLoad];
self.cameraMessage = [[ThingSmartCameraMessage alloc] initWithDeviceId:self.devId timeZone:[NSTimeZone defaultTimeZone]];
[self.cameraMessage getMessageSchemes:^(NSArray<ThingSmartCameraMessageSchemeModel *> *result) {
// The message category model.
self.schemeModels = result;
// The alerts of the first category are returned.
[self reloadMessageListWithScheme:result.firstObject];
} failure:^(NSError *error) {
// A network error.
}];
}
- (void)reloadMessageListWithScheme:(ThingSmartCameraMessageSchemeModel *)schemeModel {
NSDateFormatter *formatter = [NSDateFormatter new];
formatter.dateFormat = @"yyyy-MM-dd";
NSDate *date = [formatter dateFromString:@"2020-02-17"];
// The top 20 alerts generated in the period from 00:00:00 (UTC) on February 17, 2020 to the current time are returned.
[self.cameraMessage messagesWithMessageCodes:schemeModel.msgCodes Offset:0 limit:20 startTime:[date timeIntervalSince1970] endTime:[[NSDate new] timeIntervalSince1970] success:^(NSArray<ThingSmartCameraMessageModel *> *result) {
self.messageModelList = result;
} failure:^(NSError *error) {
// A network error.
}];
}
Swift:
func enableDectect() {
guard self.dpManager.isSupportDP(.motionDetectDPName) else {
return;
}
if let isMontionDetectOn = self.dpManager.value(forDP: .motionDetectDPName) as? Bool, !isMontionDetectOn {
self.dpManager.setValue(true, forDP: .motionDetectDPName, success: { _ in
// Motion detection is enabled.
}) { _ in
// A network error.
}
}
self.dpManager.setValue(ThingSmartCameraMotion.high, forDP: .motionSensitivityDPName, success: { _ in
// The sensitivity of motion detection is set to high sensitivity.
}) { _ in
// A network error.
}
}
override func viewDidLoad() {
super.viewDidLoad()
self.cameraMessage = ThingSmartCameraMessage(deviceId: self.devId, timeZone: NSTimeZone.default)
self.cameraMessage.getSchemes({ result in
// The alerts of the first category are returned.
self.schemeModels = result
if let schemeModel = result?.first {
reloadMessage(schemeModel: schemeModel)
}
}) { _ in
// A network error.
}
}
func reloadMessage(schemeModel: ThingSmartCameraMessageSchemeModel) {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd"
let date = formatter.date(from: "2020-02-17")
// The top 20 alerts generated in the period from 00:00:00 (UTC) on February 17, 2020 to the current time are returned.
self.cameraMessage.messages(withMessageCodes: schemeModel.msgCodes, offset: 0, limit: 20, startTime: Int(date!.timeIntervalSince1970), endTime: Int(Date().timeIntervalSince1970), success: { result in
self.messageModelList = result;
}) { _ in
// A network error.
}
}
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback