I get m3u8 or mpd file from server and i download it in my app storage. How will i play it offline. Im newbie to offline videos. Any suggestion for its usage methods. Currently i play m3u8 or mpd files with exoplayer which is Dash, HLS or progressive videos. How to play these videos offline by keeping allrights drm in mind.
https://www.exampleurl.com/playlist.m3u8?hdntl=st=16608748~exp=166797876~acl=/*~hmac=fdhf577jbjb5ss76dsd6ds78d7d6ghg78
below code i use from exoplayer sdk to find type of stream from file path lastsegment
@ContentType
public static int inferContentType(String fileName) {
fileName = toLowerInvariant(fileName);
if (fileName.endsWith(".mpd")) {
return C.TYPE_DASH;
} else if (fileName.endsWith(".m3u8")) {
return C.TYPE_HLS;
}
Matcher ismMatcher = ISM_URL_PATTERN.matcher(fileName);
if (ismMatcher.matches()) {
@Nullable String extensions = ismMatcher.group(2);
if (extensions != null) {
if (extensions.contains(ISM_DASH_FORMAT_EXTENSION)) {
return C.TYPE_DASH;
} else if (extensions.contains(ISM_HLS_FORMAT_EXTENSION)) {
return C.TYPE_HLS;
}
}
return C.TYPE_SS;
}
return C.TYPE_OTHER;
}
And How youtube offline video works?
The mpd or m3u8 files are just manifests or index files. They are text based containing information about the video and links to the media, i.e. the audio, video, subtitles etc streams.
If you want to download a HLS or DASH stream for offline playback, you will need to download the manifest and the media streams they refer to.
ExoPlayer provides functionality to help you download video and take care of much of this complexity, including specific information on downloading HLS and DASH videos - see the ExoPlayer documentation:
Note the section around tracks selection and bit rates - typically you will want to choose a particular bitrate to download rather than downloading all available ones:
For streaming playbacks, a track selector can be used to choose which of the tracks are played. Similarly, for downloading, a DownloadHelper can be used to choose which of the tracks are downloaded.
To support encrypted streams you need to ensure that the DRM server supports persistent licenses for that content and the entitlements allow offline playback - you will generally need to speak to your DRM provider to confirm this.