-
public abstract class MediaDownloadable
An abstract class that holds information related to a remote media (Video) to be downloaded and responsible to manage the download of its components such as video, audio and text.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interface
MediaDownloadable.OnVideoSizeCallback
public interface
MediaDownloadable.MediaFormatListener
Interface definition for a callback to be invoked when the video tracks have been readand are available. The tracks include Video renditions, audio languages and captions.
public interface
MediaDownloadable.DownloadEventListener
Interface definition for a callback to be invoked when a media download is either completed,cancelled or failed because an error has occurred.
-
Field Summary
Fields Modifier and Type Field Description public final static String
DEFAULT_MPD_NAME
public final static String
VIDEO_RENDITIONS
public final static String
AUDIO_LANGUAGES
public final static String
AUDIO_LANGUAGE_ROLES
public final static String
CAPTIONS
protected final Bundle
configurationBundle
protected long
estimatedSize
-
Constructor Summary
Constructors Constructor Description MediaDownloadable(Context context, Video video, MediaDownloadable.DownloadEventListener downloadEventListener, RequestConfig requestConfig)
-
Method Summary
Modifier and Type Method Description Bundle
getConfigurationBundle()
void
setConfigurationBundle(Bundle bundle)
long
getEstimatedSize()
Returns the estimated total size of the media, which includes all assets such video, audioand subtitles. abstract void
getMediaFormatTracksAvailable(@NonNull() MediaDownloadable.MediaFormatListener mediaFormatListener)
An asynchronous call to retrieve the MediaFormat tracks available for the current video. static void
registerDownloadable(@NonNull() DeliveryType deliveryType, @NonNull() Class<out MediaDownloadable> downloadableClass)
Registers the downloadable class that must be used to handled download of the specifiedmedia delivery type. static MediaDownloadable
create(@NonNull() Context context, @NonNull() Video video, @Nullable() MediaDownloadable.DownloadEventListener downloadEventListener, @Nullable() RequestConfig requestConfig)
Creates the best MediaDownloadable for the given video based on the supported delivery types. static MediaDownloadable
create(@NonNull() Context context, @NonNull() String videoUrl, @Nullable() MediaDownloadable.DownloadEventListener downloadEventListener, @Nullable() RequestConfig requestConfig)
Creates the best MediaDownloadable for the given video url on the supported delivery types. void
setVideoBitrate(int videoBitrate)
Sets the video bitrate cap which will be used to determine what rendition will be downloaded.If there's no rendition lower than the video bitrate provided, the next higher will be picked. File
getDownloadDirectory()
Gets the directory the will hold all the assets related to this media. void
estimatedSize(MediaDownloadable.OnVideoSizeCallback callback)
Returns the estimated total size of the media, which includes all assets such video, audioand subtitles. boolean
requestDownload()
Requests the media to be downloaded asynchronously. int
pauseDownload()
Attempts to pause download of this media. int
resumeDownload()
Attempts to resume download of this media. boolean
cancelDownload()
Cancels download of the media if it has not been completed yet. boolean
deleteDownload()
Deletes the offline copy of the media. DownloadStatus
getDownloadStatus()
Checks the overall download status by inspecting the status of each request in the entiredownload set. -
-
Constructor Detail
-
MediaDownloadable
MediaDownloadable(Context context, Video video, MediaDownloadable.DownloadEventListener downloadEventListener, RequestConfig requestConfig)
-
-
Method Detail
-
getConfigurationBundle
Bundle getConfigurationBundle()
-
setConfigurationBundle
void setConfigurationBundle(Bundle bundle)
-
getEstimatedSize
long getEstimatedSize()
Returns the estimated total size of the media, which includes all assets such video, audioand subtitles. Please note the method should be called after calling requestDownload
The actual size of the media that will be used by the host device may vary based on thepartition type and format of the storage.
-
getMediaFormatTracksAvailable
abstract void getMediaFormatTracksAvailable(@NonNull() MediaDownloadable.MediaFormatListener mediaFormatListener)
An asynchronous call to retrieve the MediaFormat tracks available for the current video.The result will be given through the com.brightcove.player.offline.MediaDownloadable.MediaFormatListener listener.
Note: Only the video type DASH is currently supported.
- Parameters:
mediaFormatListener
- the media format listener
-
registerDownloadable
static void registerDownloadable(@NonNull() DeliveryType deliveryType, @NonNull() Class<out MediaDownloadable> downloadableClass)
Registers the downloadable class that must be used to handled download of the specifiedmedia delivery type.
- Parameters:
deliveryType
- the deliverty typedownloadableClass
- the media downloadable class.
-
create
@Nullable() static MediaDownloadable create(@NonNull() Context context, @NonNull() Video video, @Nullable() MediaDownloadable.DownloadEventListener downloadEventListener, @Nullable() RequestConfig requestConfig)
Creates the best MediaDownloadable for the given video based on the supported delivery types.
- Parameters:
context
- the context of the application.video
- the video to be downloaded.requestConfig
- the request configuration object passed to the android.app.DownloadManager.
-
create
@Nullable() static MediaDownloadable create(@NonNull() Context context, @NonNull() String videoUrl, @Nullable() MediaDownloadable.DownloadEventListener downloadEventListener, @Nullable() RequestConfig requestConfig)
Creates the best MediaDownloadable for the given video url on the supported delivery types.
- Parameters:
context
- the context of the application.videoUrl
- the fully qualified URL of the video to be downloaded.requestConfig
- the request configuration object passed to the download manager.
-
setVideoBitrate
void setVideoBitrate(int videoBitrate)
Sets the video bitrate cap which will be used to determine what rendition will be downloaded.If there's no rendition lower than the video bitrate provided, the next higher will be picked.
- Parameters:
videoBitrate
- the video bitrate
-
getDownloadDirectory
@NonNull() File getDownloadDirectory()
Gets the directory the will hold all the assets related to this media.
-
estimatedSize
void estimatedSize(MediaDownloadable.OnVideoSizeCallback callback)
Returns the estimated total size of the media, which includes all assets such video, audioand subtitles.
The actual size of the media that will be used by the host device may vary based on thepartition type and format of the storage.This method requires the Media Manifest to estimate the size, thereforeit might download the manifest and store it to the directory provided in the ( object in the constructor, if it has not been done already.
- Parameters:
callback
- the approximate size of the media.
-
requestDownload
boolean requestDownload()
Requests the media to be downloaded asynchronously.
-
pauseDownload
int pauseDownload()
Attempts to pause download of this media.
-
resumeDownload
int resumeDownload()
Attempts to resume download of this media.
-
cancelDownload
boolean cancelDownload()
Cancels download of the media if it has not been completed yet. If the media has beendownloaded already, then calling this method will have no effect.Please call deleteDownload method instead to delete the media.
-
deleteDownload
boolean deleteDownload()
Deletes the offline copy of the media. If the media has not been fully downloadedyet, then it will be removed from the download queue and any partially download assetsbelonging to the media will be deleted.
-
getDownloadStatus
DownloadStatus getDownloadStatus()
Checks the overall download status by inspecting the status of each request in the entiredownload set. Please note that this is a blocking call. Checking the status of large mediawith multiple assets may take time.
-
-
-
-