问题描述
我编写了一个程序,可以与另一个播放器一起工作并检索有关当前播放歌曲的信息.该播放器是使用 UWP 编写的,因此 Windows 知道正在播放什么曲目,因此我可以在更改音量时看到它的名称和其他信息:
I write a some program that should work with another player and retrieve info about current playing song. That player is written using UWP, so Windows knows what track is playing, so i can see it's name and other info when changing volume:
https://i.imgur.com/nNy16Gs.png
我尝试过的事情:
var systemMediaControls = SystemMediaTransportControls.GetForCurrentView();
来自 从 Microsoft Groove 音乐应用获取当前播放曲目信息
不幸的是,据我所知,它仅适用于本地媒体,在我的应用中播放.
Unfortunately, as I understand, it's just for local media, playing from my app.
由于同样的原因,背景媒体播放器也无济于事.
Background media player doesn't helped too because of same reason.
是否有可能从 Windows 获取它?还是直接读取那个播放器的内存,呵呵?
Is it possible at all to get it from Windows? Or I should directly read memory of that player, heh?
推荐答案
音乐应用显示的屏幕控制栏不受系统控制,属于应用本身.
The screen control bar displayed by the music application is not controlled by the system but belongs to the application itself.
您无法在其他音乐软件中播放音乐,就像您无法从其他应用程序的应用程序文件夹中获取文件一样.
You don't have a way to get playing music in other music software just as you can't get files from the application folder of other applications.
无论如何,如果您只想从操作系统获取当前歌曲,则没有这样的 API.
Anyway, if you just want to get current song from OS, there’s no such API.
最好的问候.
这篇关于使用 SystemMediaTransportControls 从其他应用程序获取当前播放的歌曲信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!