C#如何访问Windows的当前播放 [英] C# How to access the current playback of windows

查看:91
本文介绍了C#如何访问Windows的当前播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows 10上有一个音乐功能(下面的图片):

at Windows 10 there is a Music Feature(Pic Below):

所以我的问题是:如何使用C#访问此信息以及需要哪些库?

So my Question is: How can I access this information with C# and which libraries do i need?

感谢您的帮助

推荐答案

对不起,请问我,但是如果我正确的话,此小部件是Spotify的弹出窗口,不是吗?在这种情况下,您只需要检查spotify进程的 MainWindowsTitle .

Excuse me for my ignorance, but if I am correct, this widget is a pop up of Spotify, isn't this? In that case, you only have to check the MainWindowsTitle of spotify process.

        var spotify = Process.GetProcessesByName("Spotify");
        foreach (var song in spotify)
        {
            Console.WriteLine(song.MainWindowTitle);
        }

        Console.ReadLine();

不要忘记使用using System.Diagnostics;.您将必须检查是否听不到任何歌曲.

Don't forget use using System.Diagnostics;. You will have to check if you don't get any song.

我正在检查此方法是否仍然有效:)

I was checking if this method works yet :)

这篇关于C#如何访问Windows的当前播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆