1.1. Voice Package Download

1.1.1. Data flow

MediaCleanRecord

1.1.2. Function Introduction

The sweeper SDK provides a voice download function, which implements the TuyaSmartSweeperDeviceDelegate proxy protocol to receive the status change callback and download progress callback during the voice download process.

Class Description
TuyaSmartSweepDevice Tuya sweeper device management class

1.1.3. Get Voice Package List

Declaration

Request the list of voice files available for the current sweeper device

- (void)getFileDownloadInfoWithSuccess:(void (^)(NSArray<TuyaSmartFileDownloadModel *> *upgradeFileList))success failure:(void (^)(NSError * _Nullable error))failure;

Parameters

Class Description
TuyaSmartFileDownloadModel The class of voice file data
Property Type Description
fileId NSString Voice file Id
productId NSString Product Id
name NSString Voice file name
desc NSString Voice file description
auditionUrl NSString Download link for audio audition file
officialUrl NSString Download link for official voice files
imgUrl NSString Voice file icon download link
region NSArray Area code
Parameter Description
success success callback(upgradeFileList:List of available voice files)
failure failure callback

Example

Objc:

[self.sweeperDevice getFileDownloadInfoWithSuccess:^(NSArray<TuyaSmartFileDownloadModel *> * _Nonnull upgradeFileList) {

    } failure:^(NSError * _Nullable error) {

    }];

Swift:

sweeperDevice?.getFileDownloadInfo(success: { (upgradeFileList) in

        }, failure: { (error) in

        })

1.1.4. Get Voice Package List by Page

Declaration

Request the list of voice files available for the current sweeper device by page.

- (void)getFileDownloadInfoWithLimit:(NSUInteger)limit offset:(NSUInteger)offset success:(void (^)(NSArray<TuyaSmartFileDownloadModel *> *upgradeFileList, NSUInteger totalCount))success failure:(void (^)(NSError * _Nullable error))failure

Parameters

Class Description
TuyaSmartFileDownloadModel The class of voice file data
Property Type Description
fileId NSString Voice file Id
productId NSString Product Id
name NSString Voice file name
desc NSString Voice file description
auditionUrl NSString Download link for audio audition file
officialUrl NSString Download link for official voice files
imgUrl NSString Voice file icon download link
region NSArray Area code
extendField NSDictionary Extend field
Parameter Description
limit The number of data obtained at a time
offset Get data offset (for paging)
success success callback(upgradeFileList:List of available voice files)
failure failure callback

Example

Objc:

[self.sweeper getFileDownloadInfoWithLimit:50 offset:0 success:^(NSArray<TuyaSmartFileDownloadModel *> * _Nonnull upgradeFileList, NSUInteger totalCount) {

    } failure:^(NSError * _Nullable error) {

    }];

Swift:

sweeperDevice?.getFileDownloadInfo(withLimit: 50, offset: 0, success: { (list, count) in

        }, failure: { (error) in

        })

1.1.5. Confirm Download Voice Package

Declaration

Confirm the download of the specified voice file

- (void)downloadFileWithFileId:(NSString *)fileId
                       success:(void (^)(id result))success
                       failure:(void (^)(NSError * _Nullable error))failure;

Parameters

Parameter Description
fileId Confirm downloaded voice file id
success success callback
failure failure callback

Example

Objc:

[self.sweeperDevice downloadFileWithFileId:<#fileId#> success:^(id  _Nonnull result) {

    } failure:^(NSError * _Nullable error) {

    }];

Swift:

sweeperDevice?.downloadFile(withFileId: "", success: { (result) in

        }, failure: { (error) in

        })

1.1.6. Get Voice Package Download Progress

Declaration

Voice file download progress data model

- (void)getFileDownloadRateWithSuccess:(void (^)(TuyaSmartFileDownloadRateModel *rateModel))success failure:(void (^)(NSError * _Nullable error))failure;

Parameters

Class Description
TuyaSmartFileDownloadRateModel File download progress information
Property Type Description
fileId NSString Voice file id
deviceId NSString Device id
status NSInteger Download status
rate int Download progress
Parameter Description
success success callback(rateModel:Voice file download progress information)
failure failure callback

Example

Objc:

[self.sweeperDevice getFileDownloadRateWithSuccess:^(TuyaSmartFileDownloadRateModel * _Nonnull rateModel) {

    } failure:^(NSError * _Nullable error) {

    }];

Swift:

sweeperDevice?.getFileDownloadRate(success: { (rateModel) in

        }, failure: { (error) in

        })

1.1.7. Voice Download Callback

Download status real-time callback

Declaration

Real-time callback of voice download status

- (void)sweeperDevice:(TuyaSmartSweeperDevice *)sweeperDevice type:(NSString *)type downloadStatus:(TuyaSmartSweeperFileDownloadStatus)status;

Parameters

TuyaSmartSweeperFileDownloadStatus Description
TuyaSmartSweeperFileDownloadUpgrading File downloading
TuyaSmartSweeperFileDownloadFinish File download completed
TuyaSmartSweeperFileDownloadFailure File download failed
Parameter Description
sweeperDevice TuyaSmartSweeperDevice instance
type File type
status Downlaod status(TuyaSmartSweeperFileDownloadStatus

Example

Objc:

self.sweeperDevice = [TuyaSmartSweeperDevice deviceWithDeviceId:<#devId#>];
self.sweeperDevice.delegate = self;

- (void)sweeperDevice:(TuyaSmartSweeperDevice *)sweeperDevice type:(NSString *)type downloadStatus:(TuyaSmartSweeperFileDownloadStatus)status {

}

Swift:

sweeperDevice = TuyaSmartSweeperDevice.init(deviceId: "your_devId")
sweeperDevice?.delegate = self

func sweeperDevice(_ sweeperDevice: TuyaSmartSweeperDevice, type: String, downloadStatus status: TuyaSmartSweeperFileDownloadStatus) {

    }

Real-time callback of download progress

Declaration

Real-time callback of voice download progress

- (void)sweeperDevice:(TuyaSmartSweeperDevice *)sweeperDevice type:(NSString *)type downloadProgress:(int)progress;

Parameters

Parameter Description
sweeperDevice TuyaSmartSweeperDevice instance
type File type
progress File download progress

Example

Objc:

self.sweeperDevice = [TuyaSmartSweeperDevice deviceWithDeviceId:<#devId#>];
self.sweeperDevice.delegate = self;

- (void)sweeperDevice:(TuyaSmartSweeperDevice *)sweeperDevice type:(NSString *)type downloadProgress:(int)progress {

}

Swift:

sweeperDevice = TuyaSmartSweeperDevice.init(deviceId: "your_devId")
sweeperDevice?.delegate = self

func sweeperDevice(_ sweeperDevice: TuyaSmartSweeperDevice, type: String, downloadProgress progress: Int32) {

    }

results matching ""

    No results matching ""