0

So I have to develop a full screen application in C#, and I was wondering if there's a way to control iTunes/Apple Music, that is running on the same PC (in the background). I would like something like play/pause, next, previous, MAAAYBE even selecting playlists.

Is this at all possible?

Laureant
  • 979
  • 3
  • 18
  • 47
  • 1
    You could try UI Automation: https://learn.microsoft.com/en-us/dotnet/framework/ui-automation/ui-automation-overview the first thing is to try the inspect tool https://learn.microsoft.com/en-us/windows/desktop/winauto/inspect-objects or UIAVerify https://learn.microsoft.com/en-us/windows/desktop/winauto/ui-automation-verify and see what you can have access too. I've tried myself and it look promising. However the "in the background" requirement may be an issue – Simon Mourier Jan 21 '19 at 09:09

1 Answers1

2

The answer to the question: "Can I automate ..." is - yes.

iTunes is a DACP-compatible music player (https://en.wikipedia.org/wiki/Digital_Audio_Control_Protocol).

There are multiple DACP implementations by the community, but the main shortcoming is that:

The DACP protocol are 100% RESTful HTTP calls that have to be reverse engineered by "sniffing" the communication between Itunes and the Apple Remote. It is a tedious task every time Apple changes something even in the slightest manner there is a lot of work to be done by the individual developers.

A decent example of how this is done: https://github.com/scott-t/iMote

However, in order to compile and run it, you need to fill the references and unless you want to compile for the framework 3.5 you need to replace some of the code. On the nice side, the Zeroconf that is used also supports .net core and async calls.

On the darker sides of grey, you have an option to decompile a application that you know already does this. Popular .net decompilers are ILSpy and ReSharper.

Margus
  • 19,694
  • 14
  • 55
  • 103