如何在spotify api上播放充满歌曲?

时间:2015-06-05 15:21:54

标签: c# wpf spotify

我只播放预览(0:30),但我想要播放充满歌曲(3:10)。 我试过某种方式,但它没有成功。它也在播放预览 我怎么玩充满歌曲的呢?

mediaplayer是MediaElement。

    mediaplayer.Source = new Uri("https://api.spotify.com/v1/tracks/4pn0G7yHNfTgRYRWca8gYA",UriKind.RelativeOrAbsolute);
or 
mediaplayer.Source = new Uri(Stream_url.preview_url.ToString(), UriKind.RelativeOrAbsolute);

"href" : "https://api.spotify.com/v1/tracks/4pn0G7yHNfTgRYRWca8gYA",
{
    "href" : "https://api.spotify.com/v1/albums/60mvULtYiNSRmpVvoa3RE4/tracks?offset=0&limit=50",
    "items" : [ {
        "artists" : [ {
            "external_urls" : {
              "spotify" : "https://open.spotify.com/artist/0TnOYISbd1XYRBk9myaseg"
            },
            "href" : "https://api.spotify.com/v1/artists/0TnOYISbd1XYRBk9myaseg",
            "id" : "0TnOYISbd1XYRBk9myaseg",
            "name" : "Pitbull",
            "type" : "artist",
            "uri" : "spotify:artist:0TnOYISbd1XYRBk9myaseg"
        }, {
            "external_urls" : {
                "spotify" : "https://open.spotify.com/artist/2DlGxzQSjYe5N6G9nkYghR"
            },
            "href" : "https://api.spotify.com/v1/artists/2DlGxzQSjYe5N6G9nkYghR",
            "id" : "2DlGxzQSjYe5N6G9nkYghR",
            "name" : "Jennifer Lopez",
            "type" : "artist",
            "uri" : "spotify:artist:2DlGxzQSjYe5N6G9nkYghR"
        }, {
            "external_urls" : {
                "spotify" : "https://open.spotify.com/artist/2OjoIDVPQKT9B7loZbPEfp"
            },
            "href" : "https://api.spotify.com/v1/artists/2OjoIDVPQKT9B7loZbPEfp",
            "id" : "2OjoIDVPQKT9B7loZbPEfp",
            "name" : "Claudia Leitte",
            "type" : "artist",
            "uri" : "spotify:artist:2OjoIDVPQKT9B7loZbPEfp"
        } ],
        "available_markets" : [ "AD", "AR", "AT", "AU", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "ES", "FR", "GR", "GT", "HK", "HN", "HU", "IE", "IS", "IT", "LI", "MC", "MT", "MX", "MY", "NI", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "RO", "SG", "SI", "SK", "SV", "TR", "TW", "UY" ],
        "disc_number" : 1,
        "duration_ms" : 222466,
        "explicit" : false,
        "external_urls" : {
            "spotify" : "https://open.spotify.com/track/4pn0G7yHNfTgRYRWca8gYA"
        },
        "href" : "https://api.spotify.com/v1/tracks/4pn0G7yHNfTgRYRWca8gYA",
        "id" : "4pn0G7yHNfTgRYRWca8gYA",
        "name" : "We Are One (Ole Ola) [The Official 2014 FIFA World Cup Song]",
        "preview_url" : "https://p.scdn.co/mp3-preview/4e6c03963fa6a6720648540282afc75f4df744c9",
        "track_number" : 1,
        "type" : "track",
        "uri" : "spotify:track:4pn0G7yHNfTgRYRWca8gYA"
    } ],
    "limit" : 50,
    "next" : null,
    "offset" : 0,
    "previous" : null,
    "total" : 1

}

1 个答案:

答案 0 :(得分:1)

在这个问题出现时,没有办法在网上播放完整曲目。对于那些将来看这个的人,您现在可以使用Web Playback SDK了!

https://beta.developer.spotify.com/documentation/web-playback-sdk/

Web Playback SDK是客户端JavaScript库,允许您在Spotify Connect中创建新播放器,并通过Encrypted Media Extensions在浏览器中播放Spotify中的任何音轨。这与我们用于支持Web Player体验的技术相同。

您可以使用Web Playback SDK执行的一些操作:

  • 在Spotify Connect中创建新播放器
  • 在支持的浏览器中流式传输音轨
  • 获取当前曲目的元数据
  • 获取有关用户收听会话的元数据
  • 控制本地播放(暂停,恢复,音量等)

快乐的黑客攻击!