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(media): add session switching functionality #162

Merged
merged 3 commits into from
Mar 21, 2025

Conversation

Dusk-afk
Copy link
Contributor

@Dusk-afk Dusk-afk commented Mar 20, 2025

This pull request adds session switching functionality to the media widget, fixes #139.
Using scroll wheel on the media widget, sessions can be switched.

  • Scroll down = Next session
  • Scroll up = Previous session

Changes:

  • Added _current_session_only decorator to ensure session update functions are called only if the session is the same as the current session.
  • Added session switching logic with switch_session method and updated play_pause, prev, and next methods to use the current session.
  • Added logic to hide the thumbnail if there is no media in the session in _on_media_properties_changed.
  • Implemented wheelEvent to switch media sessions using the mouse wheel.

Demo:

Following is a demo of the media widget handling 3 sessions:

  1. Apple Music
  2. Spotify
  3. YT Music (Browser)
Recording.2025-03-20.141811.mp4

@Video-Nomad
Copy link
Contributor

Thanks for the PR! Works really well.
Two minor things I've noticed so far:

  1. When I pause the video on YouTube and then close the tab it just gets stuck on that empty session. Is it possible to switch to the next active session if that happens?
python_y0No4WGSvZ.mp4
  1. Just some minor logging spam that's unnecessary unless it's DEBUG=True

image

@Dusk-afk
Copy link
Contributor Author

Thanks for the feedback! Glad to hear it’s working well. I've addressed both points:

  1. Implemented a check to detect when the media info is empty and the current session is closed. If this condition is met, the session will automatically switch.
  2. Added a condition to log only when DEBUG is enabled.

@amnweb amnweb merged commit c91716e into amnweb:main Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch between multiple media sources in Media widget.
3 participants