Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
fix: Handle fallback video format on CourseUnitNavigationActivity (#1835
Browse files Browse the repository at this point in the history
)

- Show fallback video in case course doesn't have any video quality available
fixes: LEARNER-9658
  • Loading branch information
omerhabib26 authored Oct 9, 2023
1 parent f9eaf0c commit 1d7f15d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ public void setData(VideoData data) {
* @return The size of the video if available, <code>-1</code> otherwise.
*/
public long getPreferredVideoEncodingSize(VideoQuality preferredVideoQuality) {
if (data != null && data.encodedVideos != null
&& data.encodedVideos.getPreferredVideoInfoForDownloading(preferredVideoQuality) != null) {
return data.encodedVideos.getPreferredVideoInfoForDownloading(preferredVideoQuality).fileSize;
if (data != null && data.encodedVideos != null) {
VideoInfo videoInfo = data.encodedVideos.getPreferredVideoInfoForDownloading(preferredVideoQuality);
if (videoInfo != null && videoInfo.fileSize > 0) {
return videoInfo.fileSize;
}
}
return -1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,15 @@ public static VideoModel getModel(VideoData vrm, VideoBlockModel block, VideoQua
e.eid = root.getCourseId();
e.duration = vrm.duration;
final VideoInfo preferredVideoInfo = vrm.encodedVideos.getPreferredVideoInfoForDownloading(videoQuality);
e.size = preferredVideoInfo.fileSize;
final VideoInfo videoInfo = vrm.encodedVideos.getPreferredNativeVideoInfo();
if (preferredVideoInfo != null) {
e.size = preferredVideoInfo.fileSize;
e.url = preferredVideoInfo.url;
} else if (videoInfo != null) {
e.size = videoInfo.fileSize;
e.url = videoInfo.url;
}
e.title = block.getDisplayName();
e.url = preferredVideoInfo.url;
e.url_hls = getVideoNetworkUrlOrNull(vrm.encodedVideos.getHls());
e.url_high_quality = getVideoNetworkUrlOrNull(vrm.encodedVideos.getMobileHigh());
e.url_low_quality = getVideoNetworkUrlOrNull(vrm.encodedVideos.getMobileLow());
Expand Down

0 comments on commit 1d7f15d

Please sign in to comment.