Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

153
Visualizações
Unable to play Spotify track in react native App

I am trying to integrate Spotify tracks in my Mobile App, I am using Spotify SDK to fetch list of liked tracks from user. In the API response, I only get track preview link that actually is the track preview media file.

In order to play the song I have to use Spotify SDK react-native-spotify-remote for react Native to pass the track_id and play the song but every time when I login and play the song it invokes the Spotify App again for new token even though the previous token is still valid and when I move to the next song it repeat this process again and doesn't even play the next song and still plays the old song.

Another problem that I am facing is that I 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.

Spotify SDK Sample Code for Player

const connectToSpotify = async () => {
 try {
const session = await SpotifyAuth.authorize(spotifyConfig);
if (session) setToken(session.accessToken);
} catch (err) {
console.log(err);
}
};
async function playEpicSong(track_id) {
try {
await SpotifyRemote.connect(token);
await SpotifyRemote.playUri(track_id);
await SpotifyRemote.seek(58000);
} catch (err) {
console.log(err);
}
}

Spotify Configuration

const spotifyConfig: ApiConfig = {
    clientID: "xxxxxxxxxxx",
    redirectURL: "mySpotify://callback",
    scopes: [
      ApiScope.AppRemoteControlScope,
      ApiScope.UserFollowReadScope,
      ApiScope.PlaylistReadPrivateScope,
      ApiScope.UserReadPlaybackStateScope,
      ApiScope.UserReadPrivateScope,
      ApiScope.UserReadEmailScope,
    ],
    
  };

Actionable button on song selection

<Pressable onPress={() => {
          playEpicSong(`${item.track_id}`);
          navigation.navigate('player');
        }}>
<Text>Play Song</Text>
</Pressable>
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda