【问题标题】:Is there a way to get the current playback time using spotify's API有没有办法使用 spotify 的 API 获取当前播放时间
【发布时间】:2019-10-18 20:04:15
【问题描述】:

我正在制作一个网络应用程序,我将在其中嵌入我的 spotify 播客片段。一旦播放了一定的秒数,我需要在我的网站上发生某些事情。有没有办法使用 API 获取播放时间?

【问题讨论】:

    标签: node.js api express spotify


    【解决方案1】:

    使用

    /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 阶段,如有更改,恕不另行通知。 (或有功能或性能问题)

    API 文档是 herehere

    【讨论】:

    • 谢谢。你知道任何播客工具的 API 还不是测试版吗?有这个功能的东西。
    • 不是特别是,但测试版并不一定意味着质量差和规格不断变化。特别是对于像 Spotify 这样的大公司,我会亲自将其用于非关键项目(例如,我不会将 beta API 用于金融科技应用程序,但播客应该没问题)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-21
    • 1970-01-01
    • 2016-02-26
    • 2020-03-27
    • 2017-07-27
    相关资源
    最近更新 更多