Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get current playing track info from Microsoft Groove Music app

I would like to get track info of the current playing track in the Microsoft Groove app in my own app. I'm talking about the Groove APP and not the REST Api.

My first approach was to try and get the Windows.Media.Playback.BackgroundMediaPlayer (now obsolete) info from my own process (app). More info about the Windows.Media.Playback.BackgroundMediaPlayer in the Dev Center Documentation

The idea was to get information from BackgroundMediaPlayer.Current but this only works in the same process. And again, this is obsolete anyway, now MS recommends using the Windows.Media.Playback.MediaPlayer class, but this is also only accessible in the same process where the MediaPlayer is used.

Second approach would be getting the information from the System Media Transport Controls.

For those not familiar with the SMTC, here's what I'm talking about (the little popup when you skip/play/pause from your keyboard for example):

enter image description here

The article about SMTC linked above shows how to use those controls in your app, the thing I want to do is basically the exact opposite.

Does anyone have an other approach you think might work?

edit

So I found out that it might be possible by using the native ISystemMediaTransportControlsInterop interface:

https://msdn.microsoft.com/en-us/library/windows/desktop/dn892315(v=vs.85).aspx

more exactly the ISystemMediaTransportControlsInterop::GetForWindow method:

https://msdn.microsoft.com/en-us/library/windows/desktop/dn892316(v=vs.85).aspx

But I don't know how to call this method, what library to use (dll) so i can (maybe) pInvoke this in my C# app.

The docs say that this is included in the Windows 10 SDK, but I can't find out where.

Maybe I'm totally wrong and maybe I can't use this in C# (because it is a C++ interface). But my idea was that this must be compiled into a library and that I can use it by using pInvoke.

It would be much appreciated if someone can explain this to me.

like image 578
Brecht Baekelandt Avatar asked Sep 25 '17 18:09

Brecht Baekelandt


People also ask

How do I get album info on Groove Music?

Groove Music can find album artwork if you right-click on the album, choose Edit Info, and then click on Find Album Info (make sure Show Advanced Options is on).

Is Groove Music obsolete?

What happened to the Groove Music Pass? The Groove Music Pass streaming service was discontinued on January 1, 2018. The Windows 10 Groove Music apps for PC and Windows Phone will continue to play all the music you've purchased and downloaded but will no longer stream or play any Groove Music Pass content.

What happened to Microsoft Groove Music?

Its subscription service Groove Music Pass was officially discontinued on December 31, 2017, and the Android and iOS versions of the Groove Music app were discontinued in December 2018, restricting the player to its native Microsoft Store base. Groove Music has been replaced by Media Player in Windows 11.

Is Groove Music better than Windows Media Player?

Groove Music is one of the apps optimised for Microsoft's Continuum* initiative and is likely to get updates more frequently than Windows Media Player. All things aside, Groove Music sounds better than Media Player.


1 Answers

https://docs.microsoft.com/en-us/uwp/api/Windows.Media.SystemMediaTransportControls

SystemMediaTransportControls _control = SystemMediaTransportControls.GetForCurrentView();

Windows.Foundation.UniversalApiContract.winmd is the contract you require to gain access to the SMTC Class.

Reference this and you should be able to gain control.

<Reference Include="Windows.Foundation.UniversalApiContract"> <HintPath>C:\Program Files (x86)\Windows Kits\10\References\Windows.Foundation.UniversalApiContract\3‌​.0.0.0\Windows.Found‌​ation.UniversalApiCo‌​ntract.winmd</HintPa‌​th> </Reference>

add this to your project file in visual studio.

I'm hoping this is what you were looking for, either way this will allow you access to the "Windows.Media" namespace.

like image 190
Enoons_ Avatar answered Oct 14 '22 23:10

Enoons_