Last Updated on : 2024-07-17 08:51:47download
Smart cameras support the cloud storage service that allows users to save video footage on the camera to the cloud.
Determine whether a device supports cloud storage. If this service is supported, proceed with the process.
Get the cloud storage service status.
Perform steps based on the service status.
If the cloud storage service is inactive or has expired, this service must be purchased to enable cloud storage.
After the cloud storage service expires, the existing cloud-stored video files will be retained for a period, seven days in most cases. At the end of this period, all cloud-stored video files will be deleted.
If the cloud storage service is within the validity period:
Demo | Class | Method | Description | Notes |
---|---|---|---|---|
ThingSmartCloudManager | + (BOOL)isSupportCloudStorage: | Check support for cloud storage. | - | |
- (instancetype)initWithDeviceId: | Create a cloud storage management object. | One device ID matches one cloud storage management object. | ||
- (void)loadCloudData: | Load cloud storage data. | The callback returns the state. If the state is valid, you can query the cloud storage data. See ThingSmartCloudState for state details. | ||
- (void)timeLineWithCloudDay:success:failure: | Query cloud-stored clips on the specified date. | Return an array of time data models ThingSmartCloudTimePieceModel for all video clips of the day. | ||
- (void)queryAIDetectConfigSuccess:failure: | Query AI-based cloud storage settings on device. |
|
||
- (void)enableAIDetect:success:failure: | Enable/disable AI-based detection. | enable: Specifies whether to enable AI-enabled detection. | ||
- (void)timeEventsWithCloudDay:offset:limit:aiCodes:success:failure: | Query cloud storage events. |
|
||
- (int)playCloudVideoWithStartTime:endTime:isEvent:onResponse:onFinished: | Start playing the cloud-stored clip. | isEvent: Indicates whether this is a cloud storage event. | ||
- (int)stopPlayCloudVideo | Stop playing the cloud-stored clip. | - | ||
- (void)destroy | Destroy resources. | - | ||
ThingSmartCloudManagerDelegate | - (void)cloudManager:didReceivedFrame:videoFrameInfo: | The delegate callback for cloud-stored video data. | The default player has been set. To customize video rendering, you can set autoRender to NO and render the video with a callback. The frameBuffer contains the YUV data of the video frames. |
To enable subscription to the cloud storage service, the Cloud Storage UI BizBundle must be integrated. This component provides the H5 pages and order display features for the subscription.
- (void)loadCloudData:(void(^)(ThingSmartCloudState state))complete;
- (void)timeLineWithCloudDay:(ThingSmartCloudDayModel *)cloudDay
success:(void(^)(NSArray<ThingSmartCloudTimePieceModel *> * timePieces))success
failure:(void(^)(NSError * error))failure;
- (void)playCloudVideoWithStartTime:(long)startTime
endTime:(long)endTime
isEvent:(BOOL)isEvent
onResponse:(void(^)(int errCode))responseCallback
onFinished:(void(^)(int errCode))finishedCallback;
- (int)stopPlayCloudVideo;
// Initialize cloud storage management class
- (void)cloudstorageManagerInit {
// Check if cloud storage is supported.
BOOL isSupportCloudStorage = [ThingSmartCloudManager isSupportCloudStorage:self.devId];
// Create a cloud storage management class
_cloudManager = [[ThingSmartCloudManager alloc] initWithDeviceId:self.devId];
[_cloudManager enableMute:NO success:nil failure:nil];
_cloudManager.delegate = self;
}
// Check cloud storage activation status
- (void)queryCloudstroageState {
__weak typeof(self) weakSelf = self;
[self.cloudManager loadCloudData:^(ThingSmartCloudState state) {
if (state == ThingSmartCloudStateValidData || state == ThingSmartCloudStateExpiredData) {
weak_self.cloudStorageDays = weak_self.cloudManager.cloudDays;
weak_self.selectedDay = weak_self.cloudManager.cloudDays.lastObject;
if (state == ThingSmartCloudStateExpiredData) {
// The cloud storage has expired. Prompt the user to subscribe.
}
} else {
// Prompt the user to subscribe to cloud storage.
}
}];
}
// Get video clips
- (void)queryTimePieces {
[self.cloudManager timeLineWithCloudDay:self.selectedDay success:^(NSArray<ThingSmartCloudTimePieceModel *> *timePieces) {
// Succeeded
} failure:^(NSError *error) {
// Failed
}];
}
// Play video clips
-(void)playVideoWithTimePiece:(ThingSmartCloudTimePieceModel *)timePiece {
[self.cloudManager playCloudVideoWithStartTime:timePiece.startTime endTime:self.selectedDay.endTime isEvent:NO onResponse:^(int errCode) {
if (errCode == 0) {
// Succeeded
}else {
// Failed
}
} onFinished:^(int errCode) {
// finished
if (errCode != 0) {
// Error
}
}];
}
// Play cloud storage event
- (void)playVideoEvent:(ThingSmartCloudTimeEventModel *)event {
[self.cloudManager playCloudVideoWithStartTime:event.startTime endTime:self.selectedDay.endTime isEvent:YES onResponse:^(int errCode) {
if (errCode == 0) {
// Succeeded
}else {
// Failed
}
} onFinished:^(int errCode) {
// finished
if (errCode != 0) {
// Error
}
}];
}
// Stop playing
- (void)stopPlayCloudVideo {
[self.cloudManager stopPlayCloudVideo];
}
// Destroy
- (void)destroy {
[self.cloudManage destroy];
}
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback