Namespace: downloads

DownstreamElectronFE.downloads

Methods

(static) create(manifestUrl, customManifestId) → {Promise}

create a new download, if success the result will contain "id" which should be used for other calls
Parameters:
Name Type Description
manifestUrl string manifest url
customManifestId string custom manifest id, if empty, null or '' the id will be generated automatically.
The manifestId is used to also store information about movie under the same folder so if you overwrite it, it will be also used as a name for folder where movie content will be stored customManifestId will be validated against default regex customManifestIdFolderRegex
Returns:
- promise
Type
Promise
Example
var url = "http://storage.googleapis.com/shaka-demo-assets/angel-one/dash.mpd";
DownstreamElectronFE.downloads.create(url)
   .then(
     function onSuccess(result) {console.log("success", result);},
     function onError(err) {console.log("error", err);
   })
DownstreamElectronFE.downloads.create(url, '<myCustomId>')
   .then(
     function onSuccess(result) {console.log("success", result);},
     function onError(err) {console.log("error", err);
   })

(static) createPersistent(manifestId, config, forcedopt) → {Promise}

create a persistent session
Parameters:
Name Type Attributes Default Description
manifestId string manifest identifier
config PersistentConfig persistent configuration
forced boolean <optional>
false replace existing persistent session, if true
Returns:
- promise
Type
Promise
Example
var config = {
  licenseUrl: 'https://lic.staging.drmtoday.com/license-proxy-widevine/cenc/',
  serverCertificate: new Uint8Array(<server_certificate>),
  customData: {
    userId: '<user_id>',
    sessionId: '<session_id>',
    merchant: '<merchant>'
  }
};
DownstreamElectronFE.downloads.createPersistent(manifestId, config)
   .then(
     function onSuccess(result) {console.log("success", result);},
     function onError(err) {console.log("error", err);
   })

(static) getFolderInfo() → {Promise}

Get info about manifest folder
Returns:
- promise
Type
Promise
Example
DownstreamElectronFE.downloads.getFolderInfo()
   .then(
     function onSuccess(result) {console.log("success", result);},
     function onError(err) {console.log("error", err);
   })

(static) getList() → {Promise}

get ids of all downloads
Returns:
- promise
Type
Promise
Example
DownstreamElectronFE.downloads.getList()
   .then(
     function onSuccess(result) {console.log("success", result);},
     function onError(err) {console.log("error", err);
   })

(static) getListWithInfo() → {Promise}

get list of all downloads with additional info manifestObject
Returns:
- promise
Type
Promise
Example
DownstreamElectronFE.downloads.getListWithInfo()
   .then(
     function onSuccess(result) {console.log("success", result);},
     function onError(err) {console.log("error", err);
   })
get offline link for download which can be used by any player to play movie
Parameters:
Name Type Description
manifestId string manifest identifier
Returns:
- promise
Type
Promise
Example
DownstreamElectronFE.downloads.getOfflineLink(manifestId)
   .then(
     function onSuccess(result) {console.log("success", result);},
     function onError(err) {console.log("error", err);
   })

(static) info(manifestId) → {Promise}

get info for download
Parameters:
Name Type Description
manifestId string manifest identifier
Returns:
- promise
Type
Promise
Example
DownstreamElectronFE.downloads.info(manifestId)
   .then(
     function onSuccess(result) {console.log("success", result);},
     function onError(err) {console.log("error", err);
   })

(static) remove(manifestId) → {Promise}

removes download
Parameters:
Name Type Description
manifestId string manifest identifier
Returns:
- promise
Type
Promise
Example
DownstreamElectronFE.downloads.remove(manifestId)
   .then(
     function onSuccess(result) {console.log("success", result);},
     function onError(err) {console.log("error", err);
   })

(static) removeAll() → {Promise}

removes all downloads
Returns:
- promise
Type
Promise
Example
DownstreamElectronFE.downloads.removeAll()
   .then(
     function onSuccess(result) {console.log("success", result);},
     function onError(err) {console.log("error", err);
   })

(static) removeAllUnfinished() → {Promise}

removes all unfinished downloads
Returns:
- promise
Type
Promise
Example
DownstreamElectronFE.downloads.removeAllUnfinished()
   .then(
     function onSuccess(result) {console.log("success", result);},
     function onError(err) {console.log("error", err);
   })

(static) removePersistent(manifestId) → {Promise}

removes persistent information previously stored
Parameters:
Name Type Description
manifestId string manifest identifier
Returns:
- promise
Type
Promise
Example
DownstreamElectronFE.downloads.removePersistent(manifestId)
   .then(
     function onSuccess(result) {console.log("success", result);},
     function onError(err) {console.log("error", err);
   })

(static) resume(manifestId) → {Promise}

resumes download which could be previously stopped or is broken
Parameters:
Name Type Description
manifestId string manifest identifier
Returns:
- promise
Type
Promise
Example
DownstreamElectronFE.downloads.resume(manifestId)
   .then(
     function onSuccess(result) {console.log("success", result);},
     function onError(err) {console.log("error", err);
   })

(static) saveData(manifestId, data) → {Promise}

Saves some user data this might be a string or json object. This data will be available as "data" property for info of download
Parameters:
Name Type Description
manifestId string manifest identifier
data string | json user data
Returns:
- promise
Type
Promise
Example
DownstreamElectronFE.downloads.saveData(manifestId, data)
   .then(
     function onSuccess(result) {console.log("success", result);},
     function onError(err) {console.log("error", err);
   })

(static) savePersistent(manifestId, persistentSessionId) → {Promise}

saves persistent session identifier
Parameters:
Name Type Description
manifestId string manifest identifier
persistentSessionId string persistent session identifier
Returns:
- promise
Type
Promise
Example
DownstreamElectronFE.downloads.savePersistent(manifestId, persistentSessionId)
   .then(
     function onSuccess(result) {console.log("success", result);},
     function onError(err) {console.log("error", err);
   })

(static) start(manifestId, representations) → {Promise}

starts download
Parameters:
Name Type Description
manifestId string manifest identifier
representations object representations to be downloaded, available options: 'video', 'audio', 'text'. For each option please provide an array of representations id to be downloaded
Returns:
- promise
Type
Promise
Example
DownstreamElectronFE.downloads.start(manifestId, {video: ['video=400000', 'video=795000'], audio: ['audio=128000']})
   .then(
     function onSuccess(result) {console.log("success", result);},
     function onError(err) {console.log("error", err);
   })

(static) stop(manifestId) → {Promise}

stops download
Parameters:
Name Type Description
manifestId string manifest identifier
Returns:
- promise
Type
Promise
Example
DownstreamElectronFE.downloads.stop(manifestId)
   .then(
     function onSuccess(result) {console.log("success", result);},
     function onError(err) {console.log("error", err);
   })

(static) stopAll() → {Promise}

stops all downloads
Returns:
- promise
Type
Promise
Example
DownstreamElectronFE.downloads.stopAll()
   .then(
     function onSuccess(result) {console.log("success", result);},
     function onError(err) {console.log("error", err);
   })

(static) subscribe(manifestId, interval, onProgress, onFinish) → {Promise}

subscribe to download progress
Parameters:
Name Type Description
manifestId string | array manifest identifier, or the array of the manifests identifier.
interval number in milliseconds - how often callback onProgress should be invoked
onProgress function callback to be invoked as often as defined by interval with stats information
onFinish function callback to be invoked when download is finished
Returns:
- promise
Type
Promise
Example
function onProgress (err, stats) {
  if (err) {
    console.logs(stats);
  }
};
function onFinish (err, info) {
  if (err) {
    console.log("error", err);
  } else {
    console.log("success", info);
  }
};
DownstreamElectronFE.downloads.subscribe(manifestId, 1000, onProgress, onFinish)
   .then(
     function onSuccess() {console.log("subscribed successfully");},
     function onError(err) {console.log("error", err);
   })

(static) unsubscribe(manifestId) → {Promise}

removes callbacks from subscribe process
Parameters:
Name Type Description
manifestId string | array manifest identifier, or the array of the manifests identifier.
Returns:
- promise
Type
Promise
Example
DownstreamElectronFE.downloads.unsubscribe(manifestId)
   .then(
     function onSuccess(result) {console.log("success", result);},
     function onError(err) {console.log("error", err);
   })

(static) updateDownloadFolder(manifestId, downloadFolder) → {Promise}

update download folder info for manifest id this can be usefule when user has copied download folder
Parameters:
Name Type Description
manifestId string manifest identifier
downloadFolder string new download folder path
Returns:
- promise
Type
Promise
Example
DownstreamElectronFE.downloads.updateDownloadFolder(manifestId, downloadFolder)
   .then(
     function onSuccess(result) {console.log("success", result);},
     function onError(err) {console.log("error", err);
   })