diff --git a/OpenEdXMobile/src/main/java/org/edx/mobile/model/course/VideoBlockModel.java b/OpenEdXMobile/src/main/java/org/edx/mobile/model/course/VideoBlockModel.java index 86b2c8ded3..3b7bb8d954 100644 --- a/OpenEdXMobile/src/main/java/org/edx/mobile/model/course/VideoBlockModel.java +++ b/OpenEdXMobile/src/main/java/org/edx/mobile/model/course/VideoBlockModel.java @@ -77,9 +77,11 @@ public void setData(VideoData data) { * @return The size of the video if available, -1 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; } diff --git a/OpenEdXMobile/src/main/java/org/edx/mobile/module/db/DatabaseModelFactory.java b/OpenEdXMobile/src/main/java/org/edx/mobile/module/db/DatabaseModelFactory.java index a150ef34cc..73bf736b85 100644 --- a/OpenEdXMobile/src/main/java/org/edx/mobile/module/db/DatabaseModelFactory.java +++ b/OpenEdXMobile/src/main/java/org/edx/mobile/module/db/DatabaseModelFactory.java @@ -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());