diff --git a/android/src/main/java/com/brentvatne/common/api/SideLoadedTextTrackList.kt b/android/src/main/java/com/brentvatne/common/api/SideLoadedTextTrackList.kt index e3d519c4..494facdc 100644 --- a/android/src/main/java/com/brentvatne/common/api/SideLoadedTextTrackList.kt +++ b/android/src/main/java/com/brentvatne/common/api/SideLoadedTextTrackList.kt @@ -11,12 +11,18 @@ import com.facebook.react.bridge.ReadableMap class SideLoadedTextTrackList { var tracks = ArrayList() + /** return true if this and src are equals */ + override fun equals(other: Any?): Boolean { + if (other == null || other !is SideLoadedTextTrackList) return false + return tracks == other.tracks + } + companion object { fun parse(src: ReadableArray?): SideLoadedTextTrackList? { if (src == null) { return null } - var sideLoadedTextTrackList = SideLoadedTextTrackList() + val sideLoadedTextTrackList = SideLoadedTextTrackList() for (i in 0 until src.size()) { val textTrack: ReadableMap = src.getMap(i) sideLoadedTextTrackList.tracks.add(SideLoadedTextTrack.parse(textTrack)) diff --git a/android/src/main/java/com/brentvatne/common/api/Source.kt b/android/src/main/java/com/brentvatne/common/api/Source.kt index b9ea8bf7..92fd9373 100644 --- a/android/src/main/java/com/brentvatne/common/api/Source.kt +++ b/android/src/main/java/com/brentvatne/common/api/Source.kt @@ -62,6 +62,11 @@ class Source { */ var cmcdProps: CMCDProps? = null + /** + * The list of sideLoaded text tracks + */ + var sideLoadedTextTracks: SideLoadedTextTrackList? = null + override fun hashCode(): Int = Objects.hash(uriString, uri, startPositionMs, cropStartMs, cropEndMs, extension, metadata, headers) /** return true if this and src are equals */ @@ -74,7 +79,8 @@ class Source { startPositionMs == other.startPositionMs && extension == other.extension && drmProps == other.drmProps && - cmcdProps == other.cmcdProps + cmcdProps == other.cmcdProps && + sideLoadedTextTracks == other.sideLoadedTextTracks ) } @@ -139,6 +145,7 @@ class Source { private const val PROP_SRC_DRM = "drm" private const val PROP_SRC_CMCD = "cmcd" private const val PROP_SRC_TEXT_TRACKS_ALLOW_CHUNKLESS_PREPARATION = "textTracksAllowChunklessPreparation" + private const val PROP_SRC_TEXT_TRACKS = "textTracks" @SuppressLint("DiscouragedApi") private fun getUriFromAssetId(context: Context, uriString: String): Uri? { @@ -198,6 +205,7 @@ class Source { source.drmProps = parse(safeGetMap(src, PROP_SRC_DRM)) source.cmcdProps = CMCDProps.parse(safeGetMap(src, PROP_SRC_CMCD)) source.textTracksAllowChunklessPreparation = safeGetBool(src, PROP_SRC_TEXT_TRACKS_ALLOW_CHUNKLESS_PREPARATION, true) + source.sideLoadedTextTracks = SideLoadedTextTrackList.parse(safeGetArray(src, PROP_SRC_TEXT_TRACKS)) val propSrcHeadersArray = safeGetArray(src, PROP_SRC_HEADERS) if (propSrcHeadersArray != null) { diff --git a/android/src/main/java/com/brentvatne/common/toolbox/ReactBridgeUtils.kt b/android/src/main/java/com/brentvatne/common/toolbox/ReactBridgeUtils.kt index 10f4752a..b4cce426 100644 --- a/android/src/main/java/com/brentvatne/common/toolbox/ReactBridgeUtils.kt +++ b/android/src/main/java/com/brentvatne/common/toolbox/ReactBridgeUtils.kt @@ -3,7 +3,6 @@ package com.brentvatne.common.toolbox import com.facebook.react.bridge.Dynamic import com.facebook.react.bridge.ReadableArray import com.facebook.react.bridge.ReadableMap -import java.util.HashMap /* * Toolbox to safe parsing of