I am new to Android development and I am trying to use the Android's Cast API. To start I have cloned and used the CastHelloText demo app. But there should be a cast button in the ActionBar/ToolBar which is for some reason not visible. I haven't registered any app to Cast Developer Console, I am just using the project as is, which means I am using the app id mentioned in their project. Does the chromecast device need to be powered on and plugged in and the android phone with the app be near/in front of the tv in order to make the button visible? I am a little confused as there is nothing mentioned anything like this in the documentation.
Your chromecast device should be powered on and on the same network as your phone (same wifi network on both). You do't need to be in front/near the TV as long as both devices are on the same wifi network but I presume you do want to be able to see the TV's screen to see if your app works or not, don't you?
Related
I have a Nexus Player on my network.
I am updating my Android App to use Google Cast V3. I have published a receiver. When I launch my app and attempt to connect to a Cast device, I only see my Chromecast devices on the network. The Nexus Player does not show up in the dialog as an option to select.
It would appear that the Receiver in the Cast Developer Console is still only seeing the test Chromecast devices, even though the Receiver is published.
Is there further configuration, possibly in the Android Manifest, that needs to be performed to allow connecting to via Google Cast to an Android TV?
It looks like I was impatient. I didn't give the Nexus Player enough time between testing my app and the publishing completed.
Thank you for spending time on my question !
Wish all of you have a good day!
Question:
①Could anybody tell me if i wanna use the Google Cast SDK to do the cast,i must have a Chromecast device?
②Can i do the cast between two android devices such as Phone and Tablet with the Google Cast SDK in my App?
③What does the receiver device in the remote display part mean? A android device with the receiver app or a special device such ac Chromecast?
Could anybody tell me if i wanna use the Google Cast SDK to do the cast,i must have a Chromecast device?
You must have something that is set up to work with the Cast protocol. That includes Chromecast devices and at least some Android TV devices.
Can i do the cast between two android devices such as Phone and Tablet with the Google Cast SDK in my App?
No, at least for any phones and tablets that I am aware of.
What does the receiver device in the remote display part mean? A android device with the receiver app or a special device such ac Chromecast?
There is no "receiver app" (unless you are referring to a custom receiver as being an app). In the Cast SDK, the receiver is running on the Chromecast/Android TV device and is responsible for playing back your requested media.
Discovery of Chromecast devices using Android MediaRouter APIs is not working as expected with latest mediarouter support library (version 19) and google play services version 4.2.43.
I'm using Cast Hello Text sample app for this issue. It can be found here: https://github.com/googlecast/CastHelloText-android.
I have my chromecast device plugged into the TV and in the same network as the Android device (Sender).
The app comes up and finds the Chromecast device. I override some of the relevant MediaRouter.Callback methods, so I see the onRouteAdded() being called.
Later, I unplug the device from my TV. I expect to get a onRouteRemoved() event. But this never happens.
The app still displays the cast icon. On selecting the device from the cast icon, the app attempts to connect to the device and fails. Now I get onRouteUnSelected() and onRouteRemoved() events and the cast icon disappears.
On plugging back the device to my TV and once the device is displaying the home screen, I expect to get a onRouteAdded() event. I do not get this event even after waiting for a few minutes.
This was working as expected in mediarouter library version 17 and with the preview google cast SDK.
So has something changed in terms of when these events are fired?
what is the right way to find out when a chromecast device is added and when it is removed? I plan on using a custom UI with MediaRouter APIs to display the cast icon and the device list.
There is a bug in the latest version of Android SDK/Play services that causes the behavior you are seeing. This will be fixed in the next release of SDK and Google Play services.
I have the MediaRouteButton working successfully. However, since I am writing an app that always uses Chromecast, I would like change a couple of behaviors of this button:
1) On app startup, automatically select a device. If there is only one device discovered, automatically select it. If there are multiple, select the previous device selected by the user.
2) If the user manually disconnects using the MediaRouteButton. presses it again to connect and there is only one device on the network, automatically select that one. This is what the YouTube app is doing now - it never prompts me with a list of devices since I only have one Chromecast device on my network.
Any suggestions?
Create your own button for selecting the ChromeCast device. Look at the TicTacToe example which does not use the MediaRouteButton. You can create your own dialog for displaying the list of devices. The logic in the TicTacToe app can also be used to automatically connect to a ChromeCast device.
Using this code, https://github.com/googlecast/cast-android-sample, I build android chromecast sample sender application.
And I also modified the code to use my appID, and uploaded whitelisted URL (already registered to Google).
But I can't find the chromecast device from this sample app. I mean, onDeviceAvailable() is not getting called. And I don't see any suspicious error / log while i am running the app.
is there anything that i need to try to see why i can't find the chromecast device?
(BTW, youtube app in the same device can find the chromecast device)
another question, which may not be related to the main question.
registering the device to have app_id, and whitelisted url is not mandatory step to find the chromecast device from app. right? I guess that registration step is needed for media stream not for device discovery.
can anyone share working sampleapp code / receiver.html? (for me to make sure that i didn't make a mistake..)
Thanks!
Did you try the Tic-tac-toe Android sample too? These two apps are using different ways of displaying the list of ChromeCast devices to the user.
Both sample apps work just fine for me. I used the default reciever.html and only added my own app id.
Technically it is not necessary to register the device to discover it on the network. You can try this app to find all DIAL devices: https://github.com/entertailion/DIAL
However, the Google Cast API wraps the DIAL discovery and they might be enforcing the app id requirement.
Ok, I think i found the cause (with help of you guys, thank you), but that does not mean that i can solve this.
TicTacToe is working because it does not need my app id. it's using something generally working (like what youtube / netflix is using).
I tried "TicTacToe" as app id for cast-android-sample app, and now it can see the chromecast device.
I tried my app id to TicTacToe and it can't show the web page on the screen. (of course i modified my receiver page that is whitelisted)
From above 2 test results, i am confident that there is something wrong with my app id.
How to solve? should i reply to "nobody#google.com" who gave me the app id? or should i register my device again? (is this ok?) i am not sure.... can anyone tell?
Assuming that you've also changed the settings on the Chromecast to send the serial to Google, then you may just need to wait a few hours after doing so. I was having the same issue where my device wouldn't show up with the sample app, after waiting a few hours after changing that setting it showed up just fine.
Did you try rebooting your device by going into your Chromecast settings via the Chromecast Android app or the Chromecast app for your computer?
I spoke to the Chromecast support team because I was having the same issue, and the reboot got it working.
To make sure that your device is whitelisted, you should be able to access this page from chrome (from a computer on the same network as your chromecast device):
<IP address of chromecast>:9222
If you can access that page, then it should work!