Skip to content
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

Feat: Add audio volume slider #691

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

SkeleyM
Copy link
Contributor

@SkeleyM SkeleyM commented Jan 6, 2025

In the name!
got absolutely terrified by the sheer volume of an audio file with no way to change it so I added it

this just simply adds a volume slider next to the mute button
image

I also updated the roadmap to reflect the features relating to audio that are currently in tagstudio

@CyanVoxel CyanVoxel added Type: QoL A quality of life (QoL) enhancement or suggestion Type: UI/UX User interface and/or user experience Priority: Medium An issue that shouldn't be be saved for last Status: Review Needed A review of this is needed labels Jan 7, 2025
Copy link
Collaborator

@VasigaranAndAngel VasigaranAndAngel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my suggestions

Comment on lines 143 to 146
self.volume_slider.setValue(int(self.player.audioOutput().volume() * 100))
else:
self.player.audioOutput().setMuted(True)
self.volume_slider.setValue(0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my suggestion is that toggling mute should only toggle mute state of the player leaving the slider untouched. that way users have more control over the volume. even when it's muted. setting the slider to 0 when muted still allows users to adjust the volume. but it doesn't unmute when the slider is changed. which feels a bit unintuitive atleast for me 😅. or it would make more sense if adjusting the slider automatically unmutes the audio.

@@ -90,6 +90,13 @@ def __init__(self, driver: "QtDriver") -> None:

self.media_btns_layout.addWidget(self.mute)

self.volume_slider = QSlider()
self.volume_slider.setValue(50)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's explicitly setting only the volume slider to 50% but not the player's volume. either make the slider reflect the player's current volume or make the player's volume reflect slider's volume. (moving this line after the one that connects the valueChanged signal ensures the player's volume matches the slider's volume. 50% in this case.)

self.volume_slider = QSlider()
self.volume_slider.setValue(50)
self.volume_slider.setOrientation(Qt.Orientation.Horizontal)
self.volume_slider.sliderMoved.connect(self.volume_slider_changed)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.volume_slider.sliderMoved.connect(self.volume_slider_changed)
self.volume_slider.valueChanged.connect(self.volume_slider_changed)

using the valueChanged signal is the proper way to handle a QSlider. the sliderMoved signal only triggers when the slider is dragged. but qslider also supports scrolling, mouse clicks, keyboard controls, and more.

@@ -207,3 +216,7 @@ def media_status_changed(self, status: QMediaPlayer.MediaStatus) -> None:
current = self.format_time(self.player.position())
duration = self.format_time(self.player.duration())
self.position_label.setText(f"{current} / {duration}")

def volume_slider_changed(self, position: int) -> None:
"""Position is divided by 100 since volume is between 0.0f and 1.0f."""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't method's docstring describe what the method does? using comments to explain specific parts of a line seems like a better approach.

Copy link
Collaborator

@VasigaranAndAngel VasigaranAndAngel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the changes ❤️. everything lgtm. minor suggestions (okay to ignore),

@@ -133,6 +141,7 @@ def toggle_mute(self) -> None:
"""Toggle the mute state of the media."""
if self.player.audioOutput().isMuted():
self.player.audioOutput().setMuted(False)
self.volume_slider.setValue(int(self.player.audioOutput().volume() * 100))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unwanted line

tagstudio/src/qt/widgets/media_player.py Outdated Show resolved Hide resolved
@CyanVoxel CyanVoxel added Status: Changes Requested Changes are quested to this and removed Status: Review Needed A review of this is needed labels Jan 9, 2025
@SkeleyM
Copy link
Contributor Author

SkeleyM commented Jan 15, 2025

sorry for taking a long time been busy with school

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Medium An issue that shouldn't be be saved for last Status: Changes Requested Changes are quested to this Type: QoL A quality of life (QoL) enhancement or suggestion Type: UI/UX User interface and/or user experience
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

3 participants