node.js - 有没有办法使用 spotify 的 API 获取当前播放时间
问题描述
我正在制作一个网络应用程序,我将在其中嵌入我的 spotify 播客剧集。一旦播放了一定的秒数,我需要在我的网站上发生某些事情。有没有办法使用 API 获取播放时间?
解决方案
利用
/v1/me/player/currently-playing
返回progress_ms
例子:
要求
curl -X GET "https://api.spotify.com/v1/me/player/currently-playing" -H "Authorization: Bearer {your access token}"
回复
{
"context": {
"external_urls" : {
"spotify" : "http://open.spotify.com/user/spotify/playlist/49znshcYJROspEqBoHg3Sv"
},
"href" : "https://api.spotify.com/v1/users/spotify/playlists/49znshcYJROspEqBoHg3Sv",
"type" : "playlist",
"uri" : "spotify:user:spotify:playlist:49znshcYJROspEqBoHg3Sv"
},
"timestamp": 1490252122574,
"progress_ms": 44272, <------
...
另请注意,此 API 处于 Beta 阶段,如有更改,恕不另行通知。(或有功能或性能问题)
推荐阅读
- memory - 如何在 Jupyter Notebook 中的每个 pyspark 作业后释放分配的内存/CPU?
- python - Python.BeautifulSoup:尝试使用 beautifulsoup 在给定样式的网站上抓取纯文本
- javascript - AJAX 重新加载间隔(轮询)帮助
- javascript - AngularJS 分页错误:无法捕获当前页面索引
- java - 在 Android Studio 中使用列表适配器和自定义列表视图时出现 NullPointerExcepter 错误
- c# - 检测 Xamarin Scrollview 何时到达末尾
- c# - 从 SQL 转换为 Linq 时 LINQ 中的替代方法/函数
- python - 在没有任何返回值的非 OOP 代码上运行单元测试
- web-crawler - 是否可以在stormcrawler中按标签爬行?
- scala - leftOuterJoin 抛出 TableException:不支持的连接类型“LEFT”