如何与 Spotify 的窗口应用程序交互 - 更改轨道等 [英] how to interact with spotify's window app -change track etc

查看:78
本文介绍了如何与 Spotify 的窗口应用程序交互 - 更改轨道等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下班后我正在做一个新的业余爱好项目,其中涉及制作我自己的自定义 C# 音乐播放器,该播放器可以从各种位置(例如 youtube、spotify 和 Windows Media Player)播放和交互

我对此进行了一些谷歌搜索,并在 Spotify 的网络播放器上找到了一堆,但在 Spotify 自己的 Windows 应用程序中却没有.

我已经完成了大部分 UI,但在与其他应用程序交互时遇到了障碍.我希望得到一些关于如何与 Spotify 等交互(更改轨道等)的建议,因为我从未做过与另一个应用程序交互的应用程序,因为我主要做 MVC 的事情.

谢谢,我感谢任何反馈

(很抱歉,如果有人问过这个问题,但显然谷歌不想给我看哈)

解决方案

您可以通过向 Spotify 窗口发送消息(至少在 Windows 上)与它进行交互.AFAIK 这只允许您发送命令,而不会接收任何信息作为回报.

您可以将 ID 为 0x0319、wparam 为 0 和特定操作的 lparam 的消息发送到 Spotify 窗口:SendMessage(spotify_hWnd, 0x0319, 0, cmd_id)

下面列出了操作的 ID.

<块引用>

 CMD_NONE = 0CMD_PLAYPAUSE = 917504CMD_MUTE = 524288CMD_VOLUMEDOWN = 589824CMD_VOLUMEUP = 655360CMD_STOP = 851968CMD_PREVIOUS = 786432CMD_NEXT = 720896

我所知道的唯一一个这样做的例子是 pytify (https://code.google.com/p/pytify/),我最近成功地使用了它.它可能需要进行一些调整(上述某些值可能不是 100% 正确)-当我回到那台计算机上时,我会研究一下我做了什么.

I'm doing a new hobby project after work which involves making my own custom C# music player, which plays and interacts from various locations such as youtube, spotify and Windows Media Player

I've done some googling on this and found a heap on spotify's web player but not for spotify's own windows application.

I've done majority of my UI but hit a brick wall with interacting with other apps. I would love some advice on how to interact (change track etc) with spotify etc, as i have never done an application which interacts with another app, as i do mostly MVC stuff.

Thanks, i appreciate any feedback

(PS sorry if this has been asked, but clearly google doesnt want to show me it ha)

解决方案

You can interact with it by sending messages to the Spotify window (at least on Windows). AFAIK this only lets you send commands though, not receive any information in return.

You can send a message with ID 0x0319, wparam of 0, and lparam of a specific action to the Spotify window: SendMessage(spotify_hWnd, 0x0319, 0, cmd_id)

The IDs for actions are listed below.

    CMD_NONE        = 0
    CMD_PLAYPAUSE   = 917504
    CMD_MUTE        = 524288
    CMD_VOLUMEDOWN  = 589824
    CMD_VOLUMEUP    = 655360
    CMD_STOP        = 851968
    CMD_PREVIOUS    = 786432
    CMD_NEXT        = 720896

The only example I know of that does this is pytify (https://code.google.com/p/pytify/), which I have used successfully somewhat recently. It may have required some tweaking (some of the above values may not be 100% correct) - I will look into what I did when I'm back on that computer.

这篇关于如何与 Spotify 的窗口应用程序交互 - 更改轨道等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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