Detecting Spotify Song Plays - android

I'm working on a mobile application that detects song plays from various media players, both on iPhone and Android. We currently support a number of applications in both platforms. Our application works in a similar way to how Last.FM detects and automatically scrobbles plays.
However, we have not been able to get a working solution for detecting Spotify song plays that does not need to use either Last.FM scrobbling (available in Spotify for Android only) or Facebook as a proxy.
I've tried a few things for android but as I understand it (I see lots of posts e.g. Find what song is playing in spotify on android), the Android Application does not broadcasts media related intents for song plays, so we need something more creative. In any case this does not solve our problem for the iPhone use case.
Lib-spotify held some promise for us, and I've manged to build an application that can create a session and navigate some playlists, but I have not figured out if I can load what would appear as "play history" in the Desktop Application via lib-spotify (e.g. is this a special form of playlist?). I have also tried a Spotify App to accomplish the same but the API appears to not to expose required functionality.
It seems like I've exhausted all avenues on this one, but does anybody have any suggestions for something I haven't tried?
Assume that I have spotify credentials for each user whose history I would like to gather.
Thanks

Spotify has a metadatachanged intent-action that contains artist, album, track, length, and id values.
See: https://stackoverflow.com/a/22195867/1345586

Unfortunately, the desktop play history is local to each machine, meaning it can't be accessed through libspotify or any other API.
At the moment, there isn't a way to reliably achieve what you're wanting to do on mobile platforms.

Related

Can I access the youtube player from external android app and get currently playing video ID and exact playing position?

Do you know, whether it is possible to access the YouTube player on a mobile phone from a self-developed android/iPhone App? In order to get the information, which video the user currently watches, and also the exact time-stamp of the played video at that moment? Is this possible?
Of course, assuming that the user would have explicitly allowed accessing this information before.
Or is Youtube running too much in its own “sandbox” and not accessible from other apps?
I was reading e.g.
Programmatically get Current Playing YouTube Video
including the answers, and am afraid that this is not possible - since I would need even more: the playing position.
If such external access of the youtube player is not possible, what could be an alternative? To provide an own, newly programmed, standalone youtube player within our app, which then would have no problems accessing such information? If so, does any one have a recommendation for a tool / tutorial that could show me, how to build such an app?
I appreciate any hints and comments!
Best regards,
Matthias

Youtube Music API for Uploaded music

Problem:
Youtube Music sucks for playing back music you have uploaded for years. The app sucks, and the Android Auto app sucks. I've contacted the YT Music team many times, but they don't seem to listen to music ever so they don't even understand the problem(s).
Solution:
Create my own app to play back my own music that lives in Google/Youtube Music. I'm an Android app developer so might as well fix this my own way.
Are there APIs for Youtube Music? I know there's an unofficial Youtube Music API, but that's phython, it doesn't build at the moment (Feb 2022), and it seems to focus on paid music, not my own uploaded library.
Would Google drive APIs do this? If so, is there documentation on how to use it? I can figure out the OAuth part, but I don't know where to get the data for the parameters in this sample api
Is there a better way for this? I just need to download the music files, and then create a player around them.
Thank you!
I was looking for something similar but the closest I got was ytmusicapi in python. It works for me and I installed it via pip install ytmusicapi. Its source is hosted on https://github.com/sigma67/ytmusicapi there, perhaps, you can see the YTM protocol. Authentication works by simply copying cookies from your browser after authenticating with YTM manually. That worked for me as well.
Another option is Kodi and a plugin they have: https://forum.kodi.tv/showthread.php?tid=360827 (but that did not seem to work for me after 3 minutes I spent on it).
If you are serious about it and you can't get YTM protocol via the source of ytmusicapi, then you can perhaps reverse-engineer the protocol using your browser. Firefox's Tools->Browser Tools->Web Developer Tools is your best friend. After you authenticate to YTM, open the "tools", click on "Library" on YTM webpage, then in "tools" tab, go to Network and look for a POST similar to https://music.youtube.com/youtubei/v1/browse?key=... right click on it and Copy->Copy as Curl. You will be able to see what auth-headers it sends and also what's the protocol for showing up your YTM Library.

How do apps like 'Rave' play Netflix inside their own app?

So the 'Rave' app let's you watch Netflix, (YouTube, .. and other streaming services) with friends. It's easy to recognize that they use Android WebView to display the source website first. They then listen to URL changes, so they can detect that user's selected video, and then play that on their own Video Player (which probably is a webview too).
Now the question is, how on earth do they manage to play Netflix on their webview player? Netflix's DRM policy requires you to have the native android app or a browser on your computer.
Since Rave are managing authentication using the WebView, they must have found a way to circumvent the barriers Netflix has placed?
This has been a really interesting case study for me. It would be great to understand the legal implications of this too.
I did a lot of digging and tried to contact the developers of the said app. They didn't respond. However upon learning how any app implements DRM on Android, the answer was obvious.
They use ExoPlayer to stream Netflix shows on their app. I confirmed this by intercepting the traffic between their app and server in my own network.
The app (exo player) was regularly exchanging certificates with the official Netflix license server, as is required by WideVine.
TLDR;
Hence the obvious answer to this is that the company behind rave has obtained the rights to stream directly from Netflix's servers, as one cannot communicate with the Netflix license server without prior permission.
This can be confirmed on the LinkedIn profile of the lead developer as he vaguely mentions that he collaborated with Netflix while working on this.
Pretty disappointed

Issues adding Chromecast support to Android App

I am attempting to integrate Google Cast into my app. I am using the CastCompanionLibrary. Integrating it is simple. ActionBar is updated with the Cast Icon. I can connect to my Chromecast devices. However, when I attempt to invoke playback, I get one of two results:
VideoCastControllerActivity starts but a spinning Loading icon displays and no video is played on the Chromecast. Only option is to hit the back button.
Only after step 1 above, Attempting to play a video just produces a Toast stating "Faile to load media"
What I can't seem to determine is if this is a problem with the App, if it resides in the content, or if it is a problem with the receiver in Google Cast Dev Console. My content is stored on a MythTV Backend and it can be HLS, MP4, MKV, AVI or 3GPP. I don't get any exceptions in the logs, not in my code or in the CastCompanionLibrary.
Any ideas on how to debug this issue?
Anyone know of a test tool that I can plug a url in to verify if the content will cast correctly on a Chromecast?
I suggest you start with simple MP4 content to first make sure that your app is set up correctly. Once you are able to play mp4, you can move to more sophisticated formats. The media formats that Chromecast supports is listed on our documentation site, so you need to limit your content to that list. The next thing to do to debug your issue, for supported formats, is to make sure that the server that is serving the content provides CORS headers since that is a requirement for almost all (but mp4) content. Finally, if that is satisfied as well, take a look at your receiver logs (turn on logging on the receiver side through the chrome console) and that should give you additional information as to why your content is not playing. To access the receiver logs/console, you need to be running your own custom receiver or your own styled receiver.

Android mediaplayer setdatasource

I have a tricky question regarding the MediaPlayer class.
I would like to find a way to play MORE than ONE online song. I though of doing it with soundcloud, but clearly the website of a playlist will not work out.
Therefore I thought of adding several string referring to single songs on soundcloud by deploying the ".setDataSource" but the app crashes, aka I cant have more than one string.
Hence, I tried with only one, but the single song's page from SoundCloud does not work either. Apparently it only works with online mp3.
Now, getting online .mp3 lawfully is rather hard nowadays and I was looking for a way to play mp3 (or m3u) from an authorised website or possibly even a playlist.
Any ideas?
Use the Google's ExoPlayer , its powerful, flexible and supports adaptive streaming. You can get to know more about it in here, also the github page.

Categories

Resources