Media-related callbacks not invoked on Chrome sender - chromecast

I'm working on a custom sender & receiver for Chromecast, using a custom HTML5 player and communicating via the built-in media channel/namespace.
When sending a message from the sender to the receiver, e.g. session.loadMedia or media.pause, they are handled correctly on the receiver. However, in the sender, neither the success not the error callback are invoked. What would I be doing wrong?

Related

Incoming call notification - Android/iOS

I am developing a voip based phone call app specially for video conferencing type calls. Everything works via normal push notifications.
how do I show incoming call screen with sound e.g.
I am trying to implement - https://developer.android.com/guide/topics/connectivity/telecom/selfManaged
not sure if I am in the right direction.
Note: I don't want to interrupt/intercept normal phone calls.
I have managed to implement this using combination of push notification, broadcast receiver, alarm service, setting window flags on activity with "FullScreenIntent".
"OnMessageReceived" set an alarm for x seconds (500ms) with Broadcast receiver
in receiver setup MainActivity intent and set flags "NewTask" and "frombackground"
In MainActivity - override "OnNewIntent", set the window flags
Window.AddFlags(WindowManagerFlags.KeepScreenOn);
Window.AddFlags(WindowManagerFlags.DismissKeyguard);
Window.AddFlags(WindowManagerFlags.ShowWhenLocked);
Window.AddFlags(WindowManagerFlags.TurnScreenOn);
Window.AddFlags(WindowManagerFlags.Fullscreen);
this will open the app in fullscreen and can be routed to appropriate page for custom UI

How ChromeCast Communicate with reciever app and sender App?

As we know we send and receive message in json form from send app to receiver app. what is the proper channel for sending and receiving message and what role ChromeCast play in whole picture?
Senders and receivers are establishing a socket connection and communicate via IPC. While it's true that this communication is in JSON format, you will likely neither generate that data yourself nor care about the 'how' or 'channels' of it - in fact, you are not even allowed to following the terms of service by Google.
Instead, you have the SDK handle that for you one both the sender and receiver site.
Communication is done in the form of defined Messages that implement a schema and contain objects - most notably for media playback that is MediaInformation.
Most of those objects that are passed between sender and receiver have a customData property that you can use to add self-defined payload in JSON format.
If you want to implement your own features you can implement custom messages.

Disconnect sender unauthorized

I am creating an app for android to support google cast for video with interaction using CastCompanionLibrary library.
On the video VideoCastManager use and for the part of the exchange of messages (data) DataManagerCast use.
I want to implement a control who can connect to a particular session. My idea is that the first sender to connect on chromecast be the "owner of the session" and other senders need to ask permission to him to connect. I created a namespace for communication between the receiver and the sender session owner for the connection process occurs.
If the sender is not authorized then it should disconnect.
I took a look at receiver reference searching for a method to the receiver disconnect a particular sende, but it still fails. Does anyone know if it is possible to implement this my idea?
First, why are you using DataCastManager? VideoCastManager can add a data channel and that is all you'd need to communicate so only use the VideoCastManager.
As far as memory serves, receiver cannot disconnect individual senders, so an alternative to your approach would be:
Each sender, after connecting to the receiver, will send a message to receiver to register itself.
Receiver looks at the number of connected devices, if that is the first one, it considers that the owner an sends back a message to the sender letting it know that it is the owner. If it is not the first one, it sends back a message to that sender, informing it that it needs to get authorization from the owner (so the new sender knows that it should wait for an authorization). At the same time, it sends a message to the owner asking for permission to allow the second one in.
The owner will send back a message to the receiver to allow or prohibit the new sender to connect. Receiver then sends a message to the new sender to let it know if its request was granted or not.
If permission was granted, then your code in your sender would allow the user to move forward in the app. If it is not granted, then the logic in your sender app can either stop the user from going forward, or can disconnect the sender, or can just limit the stuff that teh user can do.

How to pass custom data/parameters to Chromecast receiver via URL?

Is it possible to have a Chromecast sender application to pass custom data to the receiver in the URL? The goal is to pass user-specific data to the receiver so it can generate the appropriate contents each time it's called.
An example of this would be a simple to-do list. When the user casts to their device, that user's data should be passed via URL to the receiver so that their task list can be loaded in the custom receiver.
I haven't seen any tutorials or much information on this in the Cast documentation.
If you mean passing parameters as part of the receiver url that loads the receiver, the answer is no; there is no such thing. You can either use the customData that can be passed to the receiver in a number of APIs, or you can create a custom data channel if the former is not adequate for your needs.
The Cast receiver URL is specified as a static URL when you're registering/publishing the app on the Google Cast SDK Developer Console so it is not possible to add custom parameters.
However you can use the Cast Messages system to send data between a Cast sender and Cast receiver. It's similar to the messaging system in modern browsers.

Leave receiver running after sender stop

I'm using a simple receiver based on the Google CastHelloText sample app. When the sender disconnects, I'd like to allow the receiver to continue display.
I thought this could be accomplished by modifying the receiver's onSenderDisconnect function to skip the window.close call but when I disconnect my sender by calling session.stop, the receiver is shutdown withou a call to onSenderDisconnect. I see a "Dispatching shutdown event" in the receiver log.
How can I get the receiver to continue without the sender connection?
If you want to allow receiver to continue, do not call stop in your sender; that call sends a message to the receiver that would result in stoping the application on receiver; here is what the documentation for that method says: "Stops the running receiver application associated with the session.". On chrome senders, you can simply close the tab if you want to let the receiver continue . Note that the onSenderDisconnect now has an argument that shows whether disconnect was explicit (intentional) or not, in case you want to handle explicit disconnects differently. Other platforms, e.g. Android SDK, also have similar stopApplication methods that should not be called if you do not want to stop the running application on the receiver. On Android and iOS, you have more APIs to provide a more fine-tuned "disconnect" experience.

Resources