File tree Expand file tree Collapse file tree
course/src/main/java/org/openedx/course/presentation/unit/video Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -198,8 +198,9 @@ class VideoUnitFragment : Fragment(R.layout.fragment_video_unit) {
198198 val movieMetadata = MediaMetadata .Builder ()
199199 .setMediaType(MediaMetadata .MEDIA_TYPE_MOVIE )
200200 .build()
201+ val normalizedUrl = normalizeUrl(viewModel.videoUrl)
201202 val mediaItem = MediaItem .Builder ().setMediaMetadata(movieMetadata)
202- .setUri(viewModel.videoUrl )
203+ .setUri(normalizedUrl )
203204 .setMimeType(" video/*" )
204205 .build()
205206
@@ -292,6 +293,19 @@ class VideoUnitFragment : Fragment(R.layout.fragment_video_unit) {
292293 }
293294 }
294295
296+ // Convert to https when possible (helps avoid cleartext/network-security issues).
297+ private fun normalizeUrl (url : String? ): String? {
298+ if (url.isNullOrBlank()) return url
299+ val trimmed = url.trim()
300+ return try {
301+ if (trimmed.startsWith(" http://" , ignoreCase = true )) {
302+ trimmed.replaceFirst(" http://" , " https://" , ignoreCase = true )
303+ } else trimmed
304+ } catch (e: Exception ) {
305+ trimmed
306+ }
307+ }
308+
295309 companion object {
296310 private const val ARG_BLOCK_ID = " blockId"
297311 private const val ARG_VIDEO_URL = " videoUrl"
You can’t perform that action at this time.
0 commit comments