-
Notifications
You must be signed in to change notification settings - Fork 773
Tracks naming fix and minor UI improvements #2480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
phisher98
wants to merge
9
commits into
recloudstream:master
Choose a base branch
from
phisher98:video-player-media-info
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+86
−43
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
13da588
Minor Fix for case insensitive match
phisher98 a3a173f
Minor Fix for case insensitive match
phisher98 e251c4e
Minor Fix for case insensitive match and Improvement on Video Codec
phisher98 e373ffc
Minor Fix for case insensitive match and Improvement on Video Codec
phisher98 a3da693
Minor Fix for case insensitive match and Improvement on Video Codec
phisher98 a24dc24
Minor Fix for case insensitive match and Improvement on Video Codec
phisher98 7308aea
Removing Showing Index
phisher98 9505d1e
Removing Showing Index
phisher98 60a8818
Minor Changes
phisher98 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1453,45 +1453,52 @@ class GeneratorPlayer : FullScreenPlayer() { | |
|
|
||
| val audioArrayAdapter = ArrayAdapter<String>(ctx, R.layout.sort_bottom_single_choice) | ||
|
|
||
| audioArrayAdapter.addAll(currentAudioTracks.mapIndexed { index, track -> | ||
| val language = track.language?.let { fromTagToLanguageName(it) ?: it } | ||
| ?: track.label | ||
| ?: "Audio" | ||
|
|
||
| val codec = track.sampleMimeType?.let { mimeType -> | ||
| when { | ||
| mimeType.contains("mp4a") || mimeType.contains("aac") -> "aac" | ||
| mimeType.contains("ac-3") || mimeType.contains("ac3") -> "ac3" | ||
| mimeType.contains("eac3-joc") -> "Dolby Atmos" | ||
| mimeType.contains("eac3") -> "eac3" | ||
| mimeType.contains("opus") -> "opus" | ||
| mimeType.contains("vorbis") -> "vorbis" | ||
| mimeType.contains("mp3") || mimeType.contains("mpeg") -> "mp3" | ||
| mimeType.contains("flac") -> "flac" | ||
| mimeType.contains("dts") -> "dts" | ||
| else -> mimeType.substringAfter("/") | ||
| audioArrayAdapter.addAll( | ||
| currentAudioTracks.mapIndexed { _, track -> | ||
|
|
||
| val language = ( | ||
| track.language?.trim()?.let { raw -> | ||
| fromTagToLanguageName(raw) | ||
| ?: fromTagToLanguageName(raw.replace('_','-').substringBefore('-').lowercase()) | ||
| ?: raw | ||
| } | ||
| ?: track.label | ||
| ?: "Audio" | ||
| ).replaceFirstChar { it.uppercaseChar() } | ||
|
|
||
| val codec = track.sampleMimeType | ||
| ?.lowercase() | ||
| ?.let { mime -> | ||
| when { | ||
| mime.contains("eac3-joc") -> "Dolby Atmos" | ||
| mime.contains("eac3") -> "E-AC3" | ||
| mime.contains("ac-3") || mime.contains("ac3") -> "AC3" | ||
| mime.contains("mp4a") || mime.contains("aac") -> "AAC" | ||
| mime.contains("opus") -> "Opus" | ||
| mime.contains("vorbis") -> "Vorbis" | ||
| mime.contains("mp3") -> "MP3" | ||
| mime.contains("flac") -> "FLAC" | ||
| mime.contains("dts") -> "DTS" | ||
| else -> "Unknown" | ||
| } | ||
| } ?: "Unknown" | ||
|
|
||
| val channels = when (track.channelCount ?: 0) { | ||
| 1 -> "Mono" | ||
| 2 -> "Stereo" | ||
| 6 -> "5.1" | ||
| 8 -> "7.1" | ||
| else -> "${track.channelCount ?: "?"}ch" | ||
| } | ||
| } ?: "codec?" | ||
|
|
||
|
|
||
| val channels: Int = track.channelCount ?: 0 | ||
| val channelConfig = when (channels) { | ||
| 1 -> "mono" | ||
| 2 -> "stereo" | ||
| 6 -> "5.1" | ||
| 8 -> "7.1" | ||
| else -> "${channels}Ch" | ||
| } | ||
|
|
||
| listOfNotNull( | ||
| "[$index]", | ||
| language.replaceFirstChar { it.uppercaseChar() }, | ||
| codec.uppercase(), | ||
| channelConfig.replaceFirstChar { it.uppercaseChar() } | ||
| ).joinToString(" • ") | ||
|
|
||
| "[$index] $language $codec $channelConfig" | ||
| }) | ||
| listOfNotNull( | ||
| language.takeIf { it.isNotBlank() }?.replaceFirstChar { it.uppercaseChar() }, | ||
| channels.takeIf { it.isNotBlank() }?.replaceFirstChar { it.uppercaseChar() }, | ||
| codec.takeIf { it.isNotBlank() }?.uppercase()?.let { "($it)" } | ||
| ).joinToString(" ") | ||
|
|
||
| } | ||
| ) | ||
|
|
||
| audioList.adapter = audioArrayAdapter | ||
| audioList.choiceMode = AbsListView.CHOICE_MODE_SINGLE | ||
|
|
@@ -1849,6 +1856,38 @@ class GeneratorPlayer : FullScreenPlayer() { | |
| } | ||
| } | ||
|
|
||
|
|
||
| private fun videoCodecName(mime: String?): String? { | ||
| val m = mime?.lowercase() ?: return null | ||
| return when { | ||
| m.contains("avc") || m.contains("h264") -> "AVC" | ||
| m.contains("hevc") || m.contains("h265") -> "HEVC" | ||
| m.contains("av1") -> "AV1" | ||
| m.contains("vp9") -> "VP9" | ||
| m.contains("vp8") -> "VP8" | ||
| "/" in m -> m.substringAfter("/").uppercase() | ||
| else -> m.uppercase() | ||
| } | ||
| } | ||
|
|
||
| private fun audioCodecName(mime: String?): String? { | ||
| val m = mime?.lowercase() ?: return null | ||
| return when { | ||
| m.contains("eac3-joc") -> "Dolby Atmos" | ||
| m.contains("mp4a") || m.contains("aac") -> "AAC" | ||
| m.contains("ac-3") || m.contains("ac3") -> "AC3" | ||
| m.contains("eac3") -> "E-AC3" | ||
| m.contains("opus") -> "Opus" | ||
| m.contains("vorbis") -> "Vorbis" | ||
| m.contains("mp3") -> "MP3" | ||
| m.contains("flac") -> "FLAC" | ||
| m.contains("dts") -> "DTS" | ||
| "/" in m -> m.substringAfter("/").uppercase() | ||
| else -> m.uppercase() | ||
| } | ||
| } | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you thought about adding the audio channel configuration (Mono, Stereo, 5.1, ...) to the player info? |
||
|
|
||
| private fun updatePlayerInfo() { | ||
| val tracks = player.getVideoTracks() | ||
|
|
||
|
|
@@ -1859,12 +1898,16 @@ class GeneratorPlayer : FullScreenPlayer() { | |
| val prefs = PreferenceManager.getDefaultSharedPreferences(ctx) | ||
| showMediaInfo = prefs.getBoolean(ctx.getString(R.string.show_media_info_key), false) | ||
|
|
||
| val videoCodec = videoTrack?.sampleMimeType?.substringAfterLast('/')?.uppercase() | ||
| val audioCodec = audioTrack?.sampleMimeType?.substringAfterLast('/')?.uppercase() | ||
| val language = listOfNotNull( | ||
| audioTrack?.label, | ||
| fromTagToLanguageName(audioTrack?.language)?.let { "[$it]" } | ||
| ).joinToString(" ") | ||
| val videoCodec = videoCodecName(videoTrack?.sampleMimeType) | ||
| val audioCodec = audioCodecName(audioTrack?.sampleMimeType) | ||
| val languageName = fromTagToLanguageName(audioTrack?.language) | ||
| val label = audioTrack?.label | ||
|
|
||
| val language = languageName?.takeIf { it.isNotBlank() }?.let { lang -> | ||
| label?.takeIf { it.isNotBlank() && !it.equals(lang, true) } | ||
| ?.let { "$lang ($it)" } | ||
| ?: lang | ||
| } ?: label?.takeIf { it.isNotBlank() } | ||
|
|
||
| val stats = arrayOf(videoCodec, audioCodec, language).filter { !it.isNullOrBlank() }.joinToString(" • ") | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!!!!! Having ac3 before the others was preventing eac3 or eac3-joc from being properly detected.
Looking forward to seeing this PR merged.