Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Currently playing song from Windows 10 'Now Playing' card

Tags:

windows-10

uwp

Is it possible to query the metadata that is displayed when playing music on Windows 10?

http://i63.tinypic.com/1q00mc.jpg

While I found information about displaying the metadata from a MediaPlayer with SMTC and such, I can't find any way for a process (which doesn't play any media itself) to simply read out that same metadata.

like image 354
egonny Avatar asked Oct 16 '17 19:10

egonny


2 Answers

There's a .NET Framework wrapper that's able to accomplish this called WindowsMediaController.

It does it by utilizing the Windows.SDK.Contracts package to use Windows Runtime APIs in .NET Framework.

Here's a basic implementation that will print the currently playing media:

using System;
using Windows.Media.Control;

//

public static void PrintCurrentlyPlaying()
{
   var sessionManager = GlobalSystemMediaTransportControlsSessionManager.RequestAsync().GetAwaiter().GetResult();
   var currentSession = sessionManager.GetCurrentSession();
   var mediaProperties = currentSession.TryGetMediaPropertiesAsync().GetAwaiter().GetResult();
   Console.WriteLine($"Playing {mediaProperties.Title} by {mediaProperties.Artist}");
}
like image 119
DubyaDude Avatar answered Oct 02 '22 12:10

DubyaDude


This currently isn't possible, as there isn't an API that I know about that offers this.

like image 22
Tamás Deme Avatar answered Oct 02 '22 10:10

Tamás Deme