import"CustomDownloadManagerPlugin.idl";
This is a class which implements global CustomDownloadManager object. Responsible for starting a download and keeping a record of it until it is finished either with success or error. Every download should have a unique destination. User is responsible for providing a unique destination and the safety of the destination file.
void CustomDownloadManager.addEventListener |
( |
[in] String |
event_name, |
|
|
[in] EventListener |
listener |
|
) |
| |
Adds DOM2 event listener for specified event.
Possible values are: event_name: "downloadStateChange", listener: function that has arguments similar to the downloadStateChange interface properties.
- Parameters
-
event_name | Name of the event. |
listener | javascript function that has arguments like the properties listed in the listener's interface. |
enumerations CustomDownloadManager.checkDownloadPossible |
( |
[in] String |
storage_device_path, |
|
|
[in] Integer |
sizeInBytes |
|
) |
| |
Queries if the given storage has available free space in given size in bytes. Note: Destination should be the root of the storage. Root of storage is received from the StorageManager return of getListOfAvailableStorages()->RemovableDevice.path. Using registerDownloadURL does not reserve the final size of the download file so while a download is in progress Storage size decreases, meaning that the this function will have different results if there are downloads in progress. This function is most useful before starting any download. User should know the summation of the sizes of all files to be downloaded and check if this will fit. Example: A 5MB video file and a 2MB image file will be downloaded. This function should be called before starting the downloads with the parameter 7 000 000.
- Parameters
-
storage_device_path | Storage device root path. |
sizeInBytes | Free space to query. |
- Returns
- one of the following: DOWNLOAD_POSSIBLE, DOWNLOAD_INSUFFICIENT_STORAGE, DOWNLOAD_STORAGE_NOT_AVAILABLE.
Boolean CustomDownloadManager.getDownloads |
( |
| ) |
|
Requests for a list of on going downloads. Each download will invoke a downloadStateChange event with a DOWNLOAD_IN_PROGRESS status.
- Returns
- False on internal error, otherwise true.
Boolean CustomDownloadManager.isInProgress |
( |
[in] String |
destination | ) |
|
Synchronous check if the download is in progress. Note: StorageManager actions on a download destination should be performed if and only if this function returns false.
destinationPath = cdmTestDir + "file_name7.mp4";
- Parameters
-
destination | Destination that matches a download. |
- Returns
- True if download is in progress otherwise false.
Boolean CustomDownloadManager.registerDownloadURL |
( |
[in] String |
url, |
|
|
[in] String |
destination |
|
) |
| |
Gets the URL for the file which will be downloaded and destination path to where the file will be downloaded into in order to use them to start the download operation. The function can start a download from the same URL if two different destination paths are given. Each download will invoke a downloadStateChange event with a DOWNLOAD_IN_PROGRESS status. The destination path should consist of both the directory and the filename.
var invalidDownloadUrl = "http://mediatest.vestek.com.tr/SomeInvalidURL.mp4";
- Parameters
-
url | Download url of the remote file. |
destination | Optional: Download destination of the file must be under the removable storage device. If destination is left empty, platform will decide on a removable storage device and a filename. Note: if destination is decided by the platform downloading from the same url without a destination will yeild the same filename which will violate the unique destination rule, resulting an error. |
- Returns
- Returns true if download request is added successfully. If false is returned, a download to the same destination is in progress already(User will not receive an event that indicates that the download is already in progress. File will not be created for a false return so you don't need to clean it up.). Note: does not indicate result of the download
Boolean CustomDownloadManager.remove |
( |
[in] String |
destination | ) |
|
Removes a download in progress. Notes: User should use StorageManager to cleanup the destination after removal. Does not remove the file of a download that is completed.
- Parameters
-
destination | Download destination of the file. |
- Returns
- False on internal error otherwise true.
void CustomDownloadManager.removeEventListener |
( |
[in] String |
event_name, |
|
|
[in] EventListener |
listener |
|
) |
| |
Removes single DOM2 event listener for specified event
Possible values are: event_name: "downloadStateChange", listener: function that has arguments similar to the downloadStateChange interface properties.
- Parameters
-
event_name | Name of the event |
listener | named javascript function that has arguments like the properties listed in the listener's interface. |
void CustomDownloadManager.removeEventListener |
( |
[in] String |
event_name | ) |
|
const Integer CustomDownloadManager.DOWNLOAD_CANCELED_BY_USER = 3 |
remove function was called and successfully executed
const Integer CustomDownloadManager.DOWNLOAD_COMPLETED = 1 |
const Integer CustomDownloadManager.DOWNLOAD_FAILED = 8 |
const Integer CustomDownloadManager.DOWNLOAD_FILE_CREATION_ERROR = 5 |
Couldn't create the file. e.g path was invalid.
const Integer CustomDownloadManager.DOWNLOAD_FILE_WRITE_ERROR = 4 |
Couldn't write to destionation path. e.g file was deleted or file with the same name already exists in the destination path (e.g It can be checked using StorageManager listFiles API).
const Integer CustomDownloadManager.DOWNLOAD_IN_PROGRESS = 2 |
const Integer CustomDownloadManager.DOWNLOAD_INSUFFICIENT_STORAGE = 1 |
Insufficent space for download
const Integer CustomDownloadManager.DOWNLOAD_LOCAL_ERROR = 7 |
There was a problem with the local network interface.
const Integer CustomDownloadManager.DOWNLOAD_NETWORK_ERROR = 9 |
const Integer CustomDownloadManager.DOWNLOAD_PLUGIN_NOT_SUPPORTED = 10 |
const Integer CustomDownloadManager.DOWNLOAD_POSSIBLE = 0 |
Have enough space for download
const Integer CustomDownloadManager.DOWNLOAD_REMOTE_ERROR = 6 |
const Integer CustomDownloadManager.DOWNLOAD_STORAGE_NOT_AVAILABLE = 2 |
The documentation for this interface was generated from the following file:
- CustomDownloadManagerPlugin.idl