Android Question Play song of Spotify

andredamen

Active Member
Licensed User
Longtime User
I have Spotify installed on my phone.

From within my app I can play Spotify songs with an intent.

B4X:
    Dim i As Intent
    i.Initialize(i.ACTION_VIEW, SpotifySong)

    i.SetComponent("com.spotify.mobile.android.ui")
    
    StartActivity(i)

But when I do this Spotify-app appears above my app. I don't want that. Spotify-app must remain invisible. I just want to hear (and later stop) the song.

In what way is this possible. Can anyone help me?
 

ilan

Expert
Licensed User
Longtime User
try it like this:

B4X:
    Dim i As Intent
    i.Initialize(i.ACTION_VIEW,"spotify:playlist:37i9dQZF1EIUZzBgsXXF8b:play")
    StartActivity(i)
-> The Notorious BIG Mix Playlist
 
Last edited:
Upvote 0

andredamen

Active Member
Licensed User
Longtime User
try it like this:

B4X:
    Dim i As Intent
    i.Initialize(i.ACTION_VIEW,"spotify:playlist:37i9dQZF1EIUZzBgsXXF8b:play")
    StartActivity(i)
-> The Notorious BIG Mix Playlist
Ilan, I know how to play a Spotify number or list from within my app. But when I do this the app from Spotify appears. I don't want that. I must keep seeing my app at the foreground.
 
Upvote 0

andredamen

Active Member
Licensed User
Longtime User
There is indeed a Spotify Android SDK in Beta form. Too complicated for me as an amateur programmer (hobbyist). I have no knowledge of Java or converting aar files to use them in B4A.
I had pinned my hopes on expert users of B4A who had perhaps developed a library for the Spotify connection. If I read Spotify for Developers correctly, then what I'm asking (opening a Spotify song via your own app with Spotify playing in the background with your own app in the foreground) is indeed possible. Too difficult for me to achieve this via this tutorial.
For now, my hopes are pinned on the more experienced users of B4A. Who knows, maybe they can help me in the near future and thus also serve other B4A developers well.
 
Upvote 0

Similar Threads

Top