Issues adding Chromecast support to Android App - android

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.

Related

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.

Google Cast Android does not run smoothly when using local http url

My app integrates Google cast. The app is similar to Google Photos app. It allows user to browse files, then cast to chrome cast devices. Following this link: https://github.com/googlecast/CastVideos-android.
I setup local http url for my file like this: http://192.168.1.45:8989/local/storage/emulated/0/DCIM/AnyRestore/20200908_113828.mp4
Video can cast, but it is interrupted, lag even can't load the very big videos
I tried hardcoding to change the url look similar this one: https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/mp4/BigBuckBunny.mp4 like sample app above. Magically it works.
I would like to know the issue is local http url can't cast, right?. And anyone can give me know Google Photos is using https like demo app or local http like me.
I also used to Youtube, Netflix to cast. It's can cast even app is closing or force close. But Google Photos is not, cast is stoped right away if close the app. Can you explain this?
Finally, I want implement google cast function for my app like Google Photos app. Please give me any suggest.

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.

retrive only mobile-supported video from YouTube API

I'm using the YouTube API to retrieve videos for and Android client.
The program works well but sometimes I get an error like "this video is not allowed to run on smartphones".
So, there is a way to filter that videos? I read this doc but did not find a solution.
There are two concepts embeddable and syndicated.
iOS devices use iframe so they basically embed.
Android devices that use player API can check syndicated.
When you do a search->list, you can set videoEmbeddable and videoSyndicated to true.
For Android, you should check videoSyndicated.
Or if you are iterating through videos, for each video, you can do a video->list call with video id and check status.embeddable in the response.
Here is a blog post about this topic, even though examples are in v2, information is still relevant.

Detecting Spotify Song Plays

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.

Categories

Resources