Skip to content
Snippets Groups Projects
Commit 95d0d647 authored by Robert Stone's avatar Robert Stone
Browse files

Invoke getAllTracks more efficiently

parent 3560762f
No related branches found
No related tags found
1 merge request!1739Assorted small bugfixes and enhancements
......@@ -266,17 +266,11 @@ class InfoModel : ViewModel() {
mediaFactory.getFromUri(libVlc, mw.uri).apply { parse() }
}
if (!isActive) return@launch
var subs = false
val trackCount = media.getAllTracks().size
val tracks = LinkedList<IMedia.Track>()
for (i in 0 until trackCount) {
val track = media.getAllTracks()[i]
tracks.add(track)
subs = subs or (track.type == IMedia.Track.Type.Text)
}
val tracks = media.getAllTracks()
val subs = tracks.asReversed().any { it.type == IMedia.Track.Type.Text }
media.release()
hasSubs.value = subs
mediaTracks.value = tracks.toList()
mediaTracks.value = tracks
}
fun checkFile(mw: MediaWrapper) = viewModelScope.launch {
......
......@@ -108,11 +108,10 @@ class VideoStatsDelegate(private val player: VideoPlayerActivity, val scrolling:
if (lastMediaUri != media.uri) {
lastMediaUri = media.uri
binding.infoGrids.removeAllViews()
for (i in 0 until media.getAllTracks().size) {
for (track in media.getAllTracks()) {
val grid = GridLayout(player)
grid.columnCount = 2
val track = media.getAllTracks()[i]
if (track.bitrate > 0) addStreamGridView(grid, player.getString(R.string.bitrate), player.getString(R.string.bitrate_value, track.bitrate.toLong().readableSize()))
addStreamGridView(grid, player.getString(R.string.codec), track.codec)
if (track.language != null && !track.language.equals("und", ignoreCase = true))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment