Open UsamaPixarsart opened 3 years ago
hmm.. do you have any more context that you can give? I've definitely done what you are trying to do, so I know it's possible. But from what you've shown here I don't have much to go on.
@cjam, really Thanks for ur reply!
my config is:
const spotifyConfig: ApiConfig = {
clientID: 'xxxxxxxxx',
redirectURL: '<api_base_url>/api/spotify/refresh
,
tokenSwapURL: <api_base_url>/api/spotify/swap
,
scopes: [
ApiScope.AppRemoteControlScope,
ApiScope.UserFollowReadScope,
ApiScope.PlaylistReadPrivateScope,
ApiScope.UserReadPlaybackStateScope,
ApiScope.UserReadPrivateScope,
ApiScope.UserReadEmailScope,
],
};
sir, I simply get the token through this func:
const connectToSpotify = async () => { try { const session = await SpotifyAuth.authorize(spotifyConfig); if (session) setToken(session.accessToken); } catch (err) { console.log(err); } };
it opens the Spotify and redirect to my app with the token sucessfully on iOS.
But when I try to connect by providing the token like this, it does not connect or play the song:
async function playEpicSong() { try { await SpotifyRemote.connect(token); await SpotifyRemote.playUri("spotify:track:6IA8E2Q5ttcpbuahIejO74"); await SpotifyRemote.seek(58000); } catch (err) { console.log(err); } }
But If i change this to:
async function playEpicSong() { try { const session = await SpotifyAuth.authorize(spotifyConfig); await SpotifyRemote.connect(session.accessToken);
// await SpotifyRemote.connect(token);
await SpotifyRemote.playUri("spotify:track:6IA8E2Q5ttcpbuahIejO74"); await SpotifyRemote.seek(58000); } catch (err) { console.log(err); } }
and close the app and spotify, then run my app again it invokes the spotify again and gets back and play the song. But again does not play the song which I provide through uri link got by spotify web API. Can u plz help we r stuck at this for weeks now :(
Using the example snippet:
... await SpotifyRemote.playUri('spotify:track:6RUKPb4LETWmmr3iAEQktW') ...
Should play "Something Just Like This - by The Chainsmokers" but the spotify app played something else instead. Pls advice!
Edit : It works properly when the same account is online on the spotify web player. However, when the web player is closed, it doesn't work properly anymore.
Did you ever sort this problem out? Sorry I've been busy with work.
@cjam Thanks for this libray. We are developing our app using this libray. Our goal is to search the track through spotify web API and play it, const connectToSpotify = async () => { try { const session = await SpotifyAuth.authorize(spotifyConfig); if (session) setToken(session.accessToken); } catch (err) { console.log(err); } };
async function playEpicSong() { try { await SpotifyRemote.connect(token); await SpotifyRemote.playUri("spotify:track:6IA8E2Q5ttcpbuahIejO74"); await SpotifyRemote.seek(58000); } catch (err) { console.log(err); } } have to close the app and the spotify in the background then open the app and hit play it will authenticate again with spotify even last token is not expired, and the second time when we hit the play button with the changed "spotify:track:6IA8E2Q5ttcpbuahIejO74" uri it does not play that track, actually nothing happens.