从Spotify Intent开始播放歌曲 [英] Starting a Song from Spotify Intent

查看:139
本文介绍了从Spotify Intent开始播放歌曲的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

反正是否有从其URI开始Spotify跟踪的内容?

Is there anyway to start a Spotify Track from its URI ?

我尝试了以下方法,但没有一种有效.当Spotify打开时,它将始终位于播放列表"页面中,而不是位于轨道的播放器中.

I've tried the following approaches but none of them work. When Spotify opens, it always lands in the Playlists page, instead of the track's player.

String spotifyTrackURI = "spotify:track:1cC9YJ8sQjC0T5H1fXMUT2";
Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage("com.spotify.mobile.android.ui");

// I've tried with Intent#putExtra()..
launchIntent.putExtra( SearchManager.QUERY, spotifyTrackURI );
// or with setData
launchIntent.setData(Uri.parse(spotifyTrackURI))

context.startActivity(launchIntent);

谢谢

推荐答案

在Freenode(irc)的#spotify频道上找到了答案.谢谢大家!

Found the answer on the #spotify channel on Freenode (irc). Thanks everyone!

我把它放在这里让其他人知道:

I'm putting it here for other people to know about:

// right click on a track in Spotify to get the URI, or use the Web API.
String uri = "spotify:track:<spotify uri>"; 
Intent launcher = new Intent( Intent.ACTION_VIEW, Uri.parse(uri) );
startActivity(launcher);

这篇关于从Spotify Intent开始播放歌曲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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