Google Cast: Get Currently Playing Song from Audio Device - chromecast

I am trying to use the Google Cast SDK to write a tiny app.
This app should be able to show which (Google casted) song my audio system is currently playing.
This should include info about the track's title, length, artist, album etc.
Using the iOS classes I have managed to connect to the correct GCKDevice via the GCKDiscoveryManager. But how do I get the data about the track which is currently playing?
I would prefer an answer for the iOS classes, but I would also greatly appreciate any hint towards achieving the same with the Chromecast browser extension.
Addon:
On the Cast Developers +-Group I was pointed to this link, thanks Leon! I see that I should register a GCKRemoteMediaClientListener which I could do if I had a GCKRemoteMediaClientobject. The only way to get that seems to be via a GCKSession. I can create such a session from scratch but then the property remoteMediaClient is nil. Or I can ask the GCKCastContext.sharedInstance().sessionManager to start a session for me. But if I do that, the device stops playback immediately.
So I am still a bit lost about how to achieve my initial goal.
Any help please?

After some more help by Leon from the Cast Developer Group, I have figured this one out. The key information is the id of the app which is running on my audio device. I figured that out by the deprecated 2.0 API which is why I will not add this detail.
So assume you have that key, you can initialize yiur cast context by
let options = GCKCastOptions.init(receiverApplicationID: applicationID)
GCKCastContext.setSharedInstanceWith(options)
Next thing is to find your device. This was not too hard (the only thong I figured out by myself :o) and the GCKCastContext.sharedInstance().discoveryManageris your friend here.
If you now start a session via the GCKCastContext.sharedInstance().sessionManager it will not stop the playback. Totally logical in hindsight, makes me wonder which app I started before with that random app id I used...
With the session started you can cast that session to a cast session and add a session listener.
if let session = sessionManager.currentSession as? GCKCastSession {
session.add(self)
}
And when that session notifies its activeness as noted in
func castSession(_ castSession: GCKCastSession, didReceive activeInputStatus: GCKActiveInputStatus)
you can now find the long lost remoteMediaClient and register for his precious events
if let client = castSession.remoteMediaClient {
client.add(self)
}
And this will end the long journey by calling your delegate method
func remoteMediaClient(_ client: GCKRemoteMediaClient, didUpdate mediaMetadata: GCKMediaMetadata)
And if you are as I lucky as I was that media data is quite incomplete.
Mine just contained the title and the release date and nothing else.
Thanks Deezer!
But maybe I can use some id or other obtained in the whole process to get the missing data from the Deezer server? Time will tell.
In the meantime I hope this help somebody with more luck.

Related

Open iTunes with current track via my application

please help with my problem. I have mobile application of some radiostation. I use AVPlayer for playing music and get metadata, so i need to make search current track or artist(metadata) via iTunes app. I can not find any really important information about search music via my app to iTunes.(I don't want to use JSON from Apple)
So i use this code, it's very simple code but how i am understand iTunes search any information about current artist by this number 17976294 not name artist or name track:
- (IBAction)button:(id)sender {
[[UIApplication sharedApplication]
openURL:[NSURL URLWithString:#"https://itunes.apple.com/fr/artist/armin/17976294"]];
}
So maybe you have the same situation, please how to solve my problem.
UPS: So how i am understand it very-very easy, just use direct link (http://itunes.apple.com/search?term=jack+johnson&limit=25) and parse keys which we need.

Continuous playback in chromecast receiver

I need to implement continuous playback in my google cast custom receiver. For that I am handling the video event 'ended' after playing my first content, and I have to make an API call there to get the next content's media url. And now I am confusing about how can I restart playing with my new content.
Please advice.
Thanks in advance.
You can utilize MediaQueueItem (and .Builder as well) to create queue items before its being played (essentially a playlist itself). RemoteMediaPlayer.queueLoad is already used by the VideoCastManager to load and start a new queue of media items.

Chromecast new Cast.Api()

I just started using Chromecast SDK today and got bit confused with its APIs and samples given in the web.
What I am trying to do is to send some messages to the Chromecast so it will display them on the big screen. I am going to use Chrome API with HTML5/JS/CSS.
Most examples (https://github.com/pjjanak/chromecast-hello-world/blob/master/sender/index.html , http://nerdwin15.com/2013/10/chromecast-development-part-one-chrome-sender/) in the web uses new Cast.Api() in the sender and uses an Activity in doing so. But I could not find a reference to a Cast.Api in the Chrome API. Most Google references deal with Media and I am not sure whether I have to use them. So to sum up, following are the questions I have (Sorry! I did read the API and developer guide but I am still clueless).
Do I have to write a custom receiver to show text on TV screen. Can't I survive default receiver, chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID
Is handling multimedia files different from displaying text on the Chromecast or can I set the mime type to text/html and send a text stream (doesn't work for me at the moment)
Are those examples on the web uses a deprecated way of sending data to chromecast?
Thanks in advance,
Ish
Ok I think I found the answer from following documents,
https://developers.google.com/cast/docs/receiver_apps
https://github.com/googlecast/CastHelloText-chrome/blob/master/chromehellotext.html
Will try them and let you all know!
Following example page is very useful for anyone who try writing chromecast apps
https://github.com/googlecast
I'm not sure how you fared, but here are some quick responses to your questions.
Yes, you have to write a custom receiver if you want to do anything other than sending images, audio, or video to the Chromecast. You can see a list of supported media Default Media Receiver here: https://developers.google.com/cast/docs/media
Yes (see above), it requires a custom receiver, which will also require your own appId and I'm pretty sure a custom namespace.
To my knowledge, all of the examples up on https://github.com/googlecast should be relevant, but I am working on a few wrappers to try to simplify getting up and running with custom Chrome Sender and Receiver apps. You can check them out here: https://github.com/googlecast Let me know if those help, and if you have any feedback to share.
I hope you've already figured all this stuff out, but if not hopefully this is useful.

switch the cameratype in Windows Phone7

all, as we know, the CameraType property indicates the location of the camera on the device. But when I try to swich the cameratype from Primary to FrontFacing by using the following code, it does not work. After reviewing the MSDN document, I found it was a protected set method. And obviously I have no access permition. Is there any way to do that?
Could any one help me?
Thanks in advance!
camera.CameraType = CameraType.FrontFacing;
It seems like you can't force the camera to a different mode after you initialize it.
Use the constructor of the implementation.
For ex: Constructor of PhotoCamera class
I assume you're trying to create a custom camera app ? or something similar ?
If you just want to capture a picture, use Camera Capture Task instead of this. Otherwise your app will fail certification.
If photo capture is not a core feature of your application, consider using the Camera Capture Task to capture photos instead of using the camera APIs directly. Memory allocated for the Camera Capture Task does not count toward total application memory use. This helps minimize your application’s memory use, which is particularly important when your application runs on a 256-MB device. For more information, see Developing for 256-MB Devices and How to: Use the Camera Capture Task for Windows Phone.

Help me build this tool in windows envoirnment

I made a desktop music application in adobe air.
I want to update the status of some IM clients running EG: Yahoo messenger,Gtalk,AIM,MSN etc.
with the current playing song.
I am not desktop developer.This is first time i am making something for desktop.
SO is there any way in any Programming language that i can make something which will change the Data (Status message) of a running IM client.
Please Just guide me through this problem .
Edit: I dont want to ask for username/password of users IMs accounts , so via API is not a solution in this case .
It will be like Person X running mine music application and also logged to various third party IM clients (YIM,Gtalk etc).
SO if he is playing a song in the music application , then mine app will update presence status message on the IM clients to " Listening to bla bla song ".
So it is like high-jacking/Hacking the data of the running third party IM client.
Have a look at libpurple, it might have the functionality you require.
There is also telepathy, but I think it is related to the former somehow (one uses the other or they do the same thing).
EDIT: for the recent edit: it looks to me like you want something like MSN Messenger displaying the currently playing track in Windows Media Player. This requires a plugin for the messaging client, no way around that.
Perhaps an easier way to get this done would be to develop a plugin for one of the numerous multi-platform IM clients such as GAIM or Trillian. This would let you target stuff across the board without undue effort . . .
I think your only option is to write a plugin for each chat client you want to target, which could take some time.
So let me suggest an alternative: Add last.fm audioscrobbler support to your application. You would simply send the Now Playing info to last.fm via the API (http://www.last.fm/api/submissions), and it will appear on the user's profile page. Most music players already support this method because it's a pretty popular service, and a lot of people link to their last.fm profiles on their blog/facebook/etc.

Resources