JohnnyCrazy / SpotifyAPI-NET

:sound: A Client for the Spotify Web API, written in C#/.NET
http://johnnycrazy.github.io/SpotifyAPI-NET/
MIT License
1.51k stars 310 forks source link

Unable to change volume #66

Closed stuntguy3000 closed 8 years ago

stuntguy3000 commented 8 years ago

G'day again.

Whenever I reference setVolume a "Volume object creation failed" COMException is thrown. Music is playing, and other controls are fine. No stacktrace available appoligies.

Any ideas?

JimmyAppelt commented 8 years ago

Yup that is due to a fact that its hooking to the wrong process. >there are more then one processes of spotify running at the same time. And the Correct one to couple is not always at the same place in the array of coarse.

Like in #50 i commented about this issue

https://github.com/Mrnikbobjeff/SpotifyAPI-NET/commit/53ff4324258e25d035a8ea349e9c94c9abb048f8#commitcomment-14114814

Going to need something like int pid = p.Where(o => o.MainWindowHandle != IntPtr.Zero).Select(o => o.Id).First(); because i get more processes back from the Process.GetProcessesByName method. The correct Id to create the GetVolumeObject(pid) object is not always first in the array.

stuntguy3000 commented 8 years ago

Ah right, damn. No worries :)

JimmyAppelt commented 8 years ago

Don't close it :smile: it has the need to be fixed :+1:

stuntguy3000 commented 8 years ago

True :P

Mrnikbobjeff commented 8 years ago

I can not reproduce the issue with multiple processes on my Windows 10 Pro x64 system. Could you give me additional information such as os and architecture? And are multiple spotify windows open or why do you have multiple processes

JimmyAppelt commented 8 years ago

Windows 10 Pro x64

(so at least 3 processes called spotify.exe are running)

prev

int pid = p.Where(o => o.MainWindowHandle != IntPtr.Zero).Select(o => o.Id).First();

Should get you the process that has a windowhandle (where the other once have not)

JohnnyCrazy commented 8 years ago

This seems like a windows 10 problem, not ran into this with windows 7.

Could you add your OS @stuntguy3000 ? Maybe this will give us some insights.

I will deploy a fix shortly/tomorrow

Mrnikbobjeff commented 8 years ago

I did not know that spotify can have background processes. Are they they when you start spotify or when are they started?

JimmyAppelt commented 8 years ago

@Mrnikbobjeff they are started together when starting spotify itself (and run in the background)

stuntguy3000 commented 8 years ago

@JohnnyCrazy Windows 10, 64Bit, Home Premium.

stuntguy3000 commented 8 years ago

Resolved ^

racquemis commented 8 years ago

This bug seems to be back. Unable to control volume using latest binary on Windows 10 with up-to-date spotify client.

JimmyAppelt commented 8 years ago

@racquemis did it work before ?

racquemis commented 8 years ago

I couldn't tell. I've started using the Api yesterday. Everything works great except changing volume, muting and unmuting.

Also doesn't work on the older Windows Server 2012 R2 OS.

JohnnyCrazy commented 8 years ago

@racquemis Volume-Control is only possible on >Windows 7 (code)

I can't reproduce it, Volume-Control is still working.

racquemis commented 8 years ago

Hmm strange, can't get it to work. Throws the CO Mexception on all my win7 win10, server 2012 systems. It's not like the mute command is difficult to use, so I don't know what I'm doing wrong.

JohnnyCrazy commented 8 years ago

Does the full exception say anything in particular?

racquemis commented 8 years ago

Typical, now it suddenly works first try. Just did a recompile. Sorry for wasting your time. I have no idea why it suddenly starting working, but i won't complain ;)

JohnnyCrazy commented 8 years ago

Haha, no problem, I know this feeling. :sweat_smile: If you run into any other issues, feel free to open an issue