从我的iPhone应用程序打开spotify应用程序 [英] Opening spotify app from my iphone app

查看:222
本文介绍了从我的iPhone应用程序打开spotify应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很确定必须有一种方法从我自己的应用程序启动spotify iphone应用程序。我已经看到SMP应用程序(分享我的播放列表)在将播放列表推入Spotify应用程序时做了非常相似的事情。

I'm pretty sure there must be a way to launch spotify iphone app from my own app. I've seen SMP app (share my playlist) doing something very similar when pushing playlist into spotify app.

我想应该使用类似的东西:

I guess it should be by using something like:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"spotify://search:muse"]];

如您所见,我希望能够对特定关键字进行spotify搜索。问题是我真的不知道spotify url方案,如果有这样的东西可用。

As you can see, I want to be able to make spotify search for a specific keyword. The problem is I don't really know the spotify url scheme, if there is such thing available.

我一直在网上搜索,在spotify开发者网站上,但没有出现......

I've been searching in the web, in spotify developer website, etc. but nothing comes up...

推荐答案

我在应用程序中遇到了类似的需求。我的解决方案是创建一个命中Spotify API的客户端,以返回搜索的XML或JSON。例如,如果你想要Muse,你可以使用以下URL点击API:

I have run into a similar need in an app. My solution was to create a client that hits the Spotify API to return either XML or JSON of the search. For instance, if you want Muse, you would hit the API with the following URL:

http://ws.spotify.com/search/1/artist?q=muse

来自XML或JSON,您将能够在其URL方案中提取指向特定艺术家的链接:

From the XML or JSON, you'll be able to extract the link to the particular artist within their URL scheme:

spotify:artist:12Chz98pHFMPJEknJQMWvI

删掉spotify:artist:part并将其附加到Spotify艺术家链接:

Chop off the spotify:artist: portion and append that onto a Spotify artist link:

http://open.spotify.com/artist/12Chz98pHFMPJEknJQMWvI

然后,使用Spotify URL方案和UIApplication,您可以将Spotify应用程序打开到该特定艺术家的页面:

Then, using the Spotify URL scheme and UIApplication, you can open the Spotify app to that particular artist's page:

[[UIApplication sharedApplication] openURL:
   [NSURL URLWithString:
       @"spotify://http://open.spotify.com/artist/12Chz98pHFMPJEknJQMWvI"]];

注意,使用URL方案访问其他应用程序的功能通常没有文档记录,可能是一项脆弱的工作。如果将来Spotify决定改变这一点,它将在没有警告的情况下破坏此功能。

Note, using URL schemes to access features of another app is generally undocumented and can be a fragile endeavor. If Spotify in the future decides to change anything about this, it will break this functionality without warning.

这篇关于从我的iPhone应用程序打开spotify应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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