Code Monkey home page Code Monkey logo

Comments (17)

Sinono3 avatar Sinono3 commented on August 15, 2024 1

I'll work on it this week, thanks for pointing it out!

from souvlaki.

Sinono3 avatar Sinono3 commented on August 15, 2024 1

To give an update on this. I've been working on a refactor of the library which will bring in a bunch of fixes as well as add missing features such as this one. Volume is already working on my machine.

from souvlaki.

Sinono3 avatar Sinono3 commented on August 15, 2024

Got something working. Check out the volume branch. Can you test it out with your program and check if everything works?

from souvlaki.

Sinono3 avatar Sinono3 commented on August 15, 2024

Also, something I fear with this update is that MediaControlEvent is no longer Eq, maybe that will introduce a breaking change somewhere? I don't know, what do you think?

from souvlaki.

apprehensions avatar apprehensions commented on August 15, 2024

Eq? What?

what do you think?

Idk either, I have no clue about the MPRIS specification.

Also thanks! How can I test it with my program though? What can I change in the Cargo.toml files?

from souvlaki.

Sinono3 avatar Sinono3 commented on August 15, 2024

Eq? What?

The MediaControlEvent enum previously implemented the Eq trait. Since now there is an float inside it, it can no longer implement Eq. I just wonder if any programs using this library will be affected by that, but I don't think it's a big deal.

What can I change in the Cargo.toml files?

Change your current line importing souvlaki to this:

souvlaki = { git = "https://github.com/Sinono3/souvlaki", branch = "volume" }

Then of course, implement the handling of the "SetVolume" event and also use the set_volume method whenever the volume is changed internally, to maintain consistency.

from souvlaki.

thewh1teagle avatar thewh1teagle commented on August 15, 2024

I would like to use volume control on MacOS too, does it already support it?

https://stackoverflow.com/questions/11045814/emulate-media-key-press-on-mac

from souvlaki.

Sinono3 avatar Sinono3 commented on August 15, 2024

It was only implemented on Linux. I can't implement it for MacOS since I don't have access to an Apple device 😢
But this reminds me that the volume branch was never merged. @apprehensions, did you get around to using it? Did you find the behavior of volume control to be stable?

from souvlaki.

apprehensions avatar apprehensions commented on August 15, 2024

@aome510

from souvlaki.

Drigster avatar Drigster commented on August 15, 2024

Any updates, will it be released to main branch?

from souvlaki.

aome510 avatar aome510 commented on August 15, 2024

@aome510

I can't really test volume change on Linux because I don't have a Linux device

from souvlaki.

aome510 avatar aome510 commented on August 15, 2024

Great! Thanks @Sinono3. Look forward to the new changes

from souvlaki.

aome510 avatar aome510 commented on August 15, 2024

@apprehensions in case you want to test volume control with spotify_player, you can checkout https://github.com/aome510/spotify-player/tree/test-volume

diff --git a/Cargo.lock b/Cargo.lock
index 54b9060..23a78d9 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4106,9 +4106,8 @@ dependencies = [
 
 [[package]]
 name = "souvlaki"
-version = "0.6.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "951a075f224d8c87bb62a08c9c27a373fd6d453407e89cae00a25e2eac74ef51"
+version = "0.6.0"
+source = "git+https://github.com/Sinono3/souvlaki?branch=volume#0f8e6740b262958408ddc901220c4613b3f517ca"
 dependencies = [
  "block",
  "cocoa",
diff --git a/spotify_player/Cargo.toml b/spotify_player/Cargo.toml
index f5994cc..988d430 100644
--- a/spotify_player/Cargo.toml
+++ b/spotify_player/Cargo.toml
@@ -35,7 +35,7 @@ tracing = "0.1.40"
 tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
 lyric_finder = { version = "0.1.4", path = "../lyric_finder" , optional = true }
 backtrace = "0.3.69"
-souvlaki = { version = "0.6.1", optional = true }
+souvlaki = { git = "https://github.com/Sinono3/souvlaki", branch = "volume", optional = true }
 winit = { version = "0.29.4", optional = true }
 viuer = { version = "0.7.1", optional = true }
 image = { version = "0.24.7", optional = true }
diff --git a/spotify_player/src/media_control.rs b/spotify_player/src/media_control.rs
index 133e966..6bc5367 100644
--- a/spotify_player/src/media_control.rs
+++ b/spotify_player/src/media_control.rs
@@ -109,6 +109,11 @@ pub fn start_event_watcher(
                     .send(ClientRequest::Player(PlayerRequest::PreviousTrack))
                     .unwrap_or_default();
             }
+            MediaControlEvent::SetVolume(volume) => client_pub
+                .send(ClientRequest::Player(PlayerRequest::Volume(
+                    (volume * 100.0) as u8,
+                )))
+                .unwrap_or_default(),
             _ => {}
         }
     })?;

from souvlaki.

thewh1teagle avatar thewh1teagle commented on August 15, 2024

@Sinono3
Does it support volume on macos now?

from souvlaki.

Sinono3 avatar Sinono3 commented on August 15, 2024

Just pushed version 0.7 which should have volume control for Linux.

Does it support volume on macos now?

No, sorry. I plan on buying a Mac soon. There won't be support until then or until someone else implements it. I'll create other issues for the other OSes.

from souvlaki.

LucasFA avatar LucasFA commented on August 15, 2024

I am happy to report that testing with the following command:

dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify_player /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Set string:'org.mpris.MediaPlayer2.Player' string:'Volume' variant:double:0.4

Reveals that, yes the test_volume branch of spotify_player works as intended with souvlaki. Souvlaki 0.7.0 also works.

from souvlaki.

Sinono3 avatar Sinono3 commented on August 15, 2024

@LucasFA Thanks for testing! 🙂

from souvlaki.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.