-
-
Notifications
You must be signed in to change notification settings - Fork 159
feat: add no_sound icon for videos without an audio track #881
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
base: main
Are you sure you want to change the base?
Conversation
| // Get the format of the first track in the group to check its type. | ||
| val format = group.getTrackFormat(0) | ||
| // Check if the MIME type is an audio type (e.g., "audio/mp4a-latm"). | ||
| format.sampleMimeType?.startsWith("audio/") == true | ||
| } | ||
| } ?: false // |
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.
| // Get the format of the first track in the group to check its type. | |
| val format = group.getTrackFormat(0) | |
| // Check if the MIME type is an audio type (e.g., "audio/mp4a-latm"). | |
| format.sampleMimeType?.startsWith("audio/") == true | |
| } | |
| } ?: false // | |
| val format = group.getTrackFormat(0) | |
| format.sampleMimeType?.startsWith("audio/") == true | |
| } | |
| } ?: false |
Please avoid obvious comments. Are you using some AI coding agent?
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.
Sorry about that. Yes I am using Gemini on Android Studio. Will do the changes..
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.
For your information, even the latest Gemini model has a high hallucination rate. As of now, AI code contributions are usually not accepted in Fossify (mentioned in the guidelines).
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.
Will keep that in mind, however, I don't copy paste the code without going through it. Will refrain from using the model here from now on :)
| } ?: false // | ||
| if (!mHasAudio) { | ||
| binding.bottomVideoTimeHolder.videoToggleMute.setImageResource(R.drawable.no_sound) | ||
| binding.bottomVideoTimeHolder.videoToggleMute.isClickable = false |
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.
It should show a toast instead, as I proposed here. That's more user-friendly in this case.
I like This video has no audio.
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.
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.
Yes. The new icon + toast This video has no audio on click. We can still slightly reduce the alpha (MEDIUM_ALPHA) to get the disabled effect.
CHANGELOG.md
Outdated
| ## [Unreleased] | ||
| ### Added | ||
| - Long press gesture to play videos at 2x speed in separate video player ([#830]) | ||
| - Added a dedicated icon for videos without an audio track ([#876]) |
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.
It should go under the changed section:
| - Added a dedicated icon for videos without an audio track ([#876]) | |
| ### Changed | |
| - Mute button is now disabled for videos without an audio track ([#876]) |
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="24dp" | ||
| android:height="24dp" | ||
| android:viewportWidth="960" | ||
| android:viewportHeight="960" | ||
| android:tint="?attr/colorControlNormal" | ||
| android:autoMirrored="true"> | ||
| <path | ||
| android:fillColor="@android:color/white" | ||
| android:pathData="M616,640L560,584L664,480L560,376L616,320L720,424L824,320L880,376L776,480L880,584L824,640L720,536L616,640ZM120,600L120,360L280,360L480,160L480,800L280,600L120,600ZM400,354L314,440L200,440L200,520L314,520L400,606L400,354ZM300,480L300,480L300,480L300,480L300,480L300,480Z"/> | ||
| </vector> |
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.
File should be named ic_vector_no_sound.xml. See guidelines.
| private fun checkAudioTrack() { | ||
| mHasAudio = mExoPlayer?.let { player -> | ||
| if (player.currentTracks.groups.isEmpty()) { | ||
| return@let false | ||
| } | ||
|
|
||
| player.currentTracks.groups.any { group -> | ||
| // Get the format of the first track in the group to check its type. | ||
| val format = group.getTrackFormat(0) | ||
| // Check if the MIME type is an audio type (e.g., "audio/mp4a-latm"). | ||
| format.sampleMimeType?.startsWith("audio/") == true | ||
| } | ||
| } ?: false // | ||
| if (!mHasAudio) { | ||
| binding.bottomVideoTimeHolder.videoToggleMute.setImageResource(R.drawable.no_sound) | ||
| binding.bottomVideoTimeHolder.videoToggleMute.isClickable = false | ||
| } | ||
| } | ||
|
|
||
| private fun videoPrepared() { | ||
| checkAudioTrack() |
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.
It'll be simpler and more reliable to use the existing player listener:
// add in initListeners()
override fun onTracksChanged(tracks: Tracks) {
updatePlayerMuteState(tracks.containsType(C.TRACK_TYPE_AUDIO))
}The click listener and updatePlayerMuteState() should be reworked to accept hasAudio and process the click as required (mute/unmute or show toast).
| if (!mHasAudio) { | ||
| binding.bottomVideoTimeHolder.videoToggleMute.setImageResource(R.drawable.no_sound) | ||
| binding.bottomVideoTimeHolder.videoToggleMute.isClickable = false | ||
| } | ||
|
|
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.
This shouldn't be needed here with the listener based approach.
| private fun checkAudioTrack() { | ||
| mHasAudio = mExoPlayer?.let { player -> | ||
| if (player.currentTracks.groups.isEmpty()) { | ||
| return@let false | ||
| } | ||
|
|
||
| player.currentTracks.groups.any { group -> | ||
| // Get the format of the first track in the group to check its type. | ||
| val format = group.getTrackFormat(0) | ||
| // Check if the MIME type is an audio type (e.g., "audio/mp4a-latm"). | ||
| format.sampleMimeType?.startsWith("audio/") == true | ||
| } | ||
| } ?: false // | ||
| if (!mHasAudio) { | ||
| binding.bottomVideoTimeHolder.videoToggleMute.setImageResource(R.drawable.no_sound) | ||
| binding.bottomVideoTimeHolder.videoToggleMute.isClickable = false | ||
| } | ||
| } | ||
|
|
||
| private fun videoPrepared() { | ||
| checkAudioTrack() |
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.
Same suggestions as the VideoPlayerActivity.
|
@naveensingh done with the changes, I didn't know if the new string property should be in strings.xml, can move it if needed. |
app/src/main/res/values/strings.xml
Outdated
|
|
||
| <!-- Player--> | ||
| <string name="video_no_sound">This video has no sound</string> |
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.
Please move this section above the FAQ related strings.
I think "audio" fits better than "sound".
| <!-- Player--> | |
| <string name="video_no_sound">This video has no sound</string> | |
| <!-- Player--> | |
| <string name="video_no_sound">This video has no audio</string> |
| if (!mWasVideoStarted) { | ||
| if (!mHasAudio) { | ||
| toast(R.string.video_no_sound) | ||
| } | ||
| } | ||
|
|
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.
By toast on click, I meant we should show a toast when there is no audio and the mute button is clicked. More info in #881 (comment).
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.
By toast on click, I meant we should show a toast when there is no audio and the mute button is clicked. More info in #881 (comment).
done, it will now show the toast only when the mute button is clicked, provided video was started previously in the same player session
Type of change(s)
What changed and why
Tests performed
Preview
Closes the following issue(s)
Checklist
CHANGELOG.md(if applicable).