1. Voice Package Download

1.1. Data flow

download

Note

  • The development platform cannot find the configuration voice package entry. You need to submit the information to the project manager or business person responsible for your project.

1.2. Function Introduction

The sweeper SDK provides functions such as downloading voice packets and monitoring progress.

Function entrance :

ITuyaSweeperKitSdk iTuyaSweeperKitSdk = TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class);

ITuyaSweeperFileDownload iTuyaSweeperFileDownload = iTuyaSweeperKitSdk.newFileDownloadInstance(devId);

1.3. Get Voice Package List

Interface Description

  • Old version (version before 0.1.0): Not supported
  • New version (version after 0.1.0): support

    void getFileList(final ITuyaResultCallback<ArrayList<SweeperFileListInfoBean>> callback);
    

1.3.1. SweeperFileListInfoBean Data structure information

Fields Type Description
id long Voice file id
name String Voice file name
desc String Voice file description
auditionUrl String Test of the voice file url
officialUrl String Official voice file url
imgUrl String Voice file icon url
region List region code

Sample Code

ITuyaSweeperKitSdk iTuyaSweeperKitSdk = TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class);

ITuyaSweeperFileDownload iTuyaSweeperFileDownload = iTuyaSweeperKitSdk.newFileDownloadInstance(devId);

iTuyaSweeperFileDownload.getFileList(new ITuyaResultCallback<ArrayList<SweeperFileListInfoBean>>() {
    @Override
    public void onSuccess(ArrayList<SweeperFileListInfoBean> result) {

    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});

1.4. Registration and Unregistration Download Monitoring

Interface Description

  • Old version (version before 0.1.0): Not supported
  • New version (version after 0.1.0): support
void registerDownloadListener(final ISweeperFileDownloadListener listener)

void unRegisterDownloadListener();

ISweeperFileDownloadListener


/**
 *
 * @param type file Type,Voice file is DOWNLOAD_VOICE
 * @param fileDownloadEnum Enumeration, including download completion and download failure
 */
void onResultStatus(String type, SweeperFileDownloadEnum fileDownloadEnum);

/**
 *
 * @param type
 * @param progress Download progress
 */
void onProgress(String type, int progress);

Sample Code


ITuyaSweeperKitSdk iTuyaSweeperKitSdk = TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class);

ITuyaSweeperFileDownload iTuyaSweeperFileDownload = iTuyaSweeperKitSdk.newFileDownloadInstance(devId);


iTuyaSweeperFileDownload.registerDownloadListener(new ISweeperFileDownloadListener() {
    @Override
    public void onResultStatus(String type, SweeperFileDownloadEnum fileDownloadEnum) {

    }

    @Override
    public void onProgress(String type, int progress) {

    }
});
iTuyaSweeperFileDownload.unRegisterDownloadListener();

1.5. Confirm Download Voice File

Interface Description

  • Old version (version before 0.1.0): Not supported
  • New version (version after 0.1.0): support
/**
 * 
 * @param fileId   Voicie file id
 * @param callback
 */
void confirmDownload(long fileId, final ITuyaResultCallback<Integer> callback);

Sample Code

ITuyaSweeperKitSdk iTuyaSweeperKitSdk = TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class);

ITuyaSweeperFileDownload iTuyaSweeperFileDownload = iTuyaSweeperKitSdk.newFileDownloadInstance(devId);

iTuyaSweeperFileDownload.confirmDownload(1000, new ITuyaResultCallback<Integer>() {
    @Override
    public void onSuccess(Integer result) {

    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});

1.6. Get Voice Package Download Progress

Interface Description

  • Old version (version before 0.1.0): Not supported
  • New version (version after 0.1.0): support
void queryProgress(final ITuyaResultCallback<SweeperProgressbean> callback);

SweeperProgressbean:

Fields Type Description
id long Voice file id
rate int Download progress
status int Status(0:Not downloaded 1:Downloading)

Sample Code


ITuyaSweeperKitSdk iTuyaSweeperKitSdk = TuyaOptimusSdk.getManager(ITuyaSweeperKitSdk.class);

ITuyaSweeperFileDownload iTuyaSweeperFileDownload = iTuyaSweeperKitSdk.newFileDownloadInstance(devId);

iTuyaSweeperFileDownload.queryProgress(new ITuyaResultCallback<SweeperProgressbean>() {
    @Override
    public void onSuccess(SweeperProgressbean result) {

    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});

1.7. Destroy

Interface Description

  • Old version (version before 0.1.0): Not supported
  • New version (version after 0.1.0): support

When exiting the download, destroy the download function

 void onDestroy();

results matching ""

    No results matching ""