Change the client application name on ChromeCast Default Media Receiver - android

I want to change the text "Default Media Receiver" which is displayed on the audio playback page of the Chromecast Default Media Receiver, but not the video playback page, to anything but that. I'm developing an Android app.
I'm having difficulty getting my website hosting service to enable SSL. They won't do it unless I upgrade to dedicated IP address even for a self-signed cert, at considerable expense). So I'm stuck with a choice between styled receiver/no stylesheet, and the Default Media Receiver. (Yes, a change of hosting services is in the wind. Don't ask).
I rather prefer the appearance of the Default Media Receiver. It starts up faster, and the Cast icon on the startup page instead of my app name is nicer.
Except for one small irritating detail. When playing audio tracks on the Default Media Receiver, the title of the application ("Default Media Receiver") is displayed on the otherwise very beautiful page on the Chromecast device when playing audio tracks.
Is there any way to change this without resorting to a styled media receiver?
(eyeroll directed to response in comment...Here's the code. I already described what I tried.)
#Override
public CastOptions getCastOptions(Context context) {
return new CastOptions.Builder()
// Use this line for styled/no-style-sheet.
//.setReceiverApplicationId(context.getString(R.string.cast_app_id))
// use this line for default receiver.
.setReceiverApplicationId(
CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID)
.build();
}

There is now an option to use a "Styled Media Receiver" without having to serve content from your own Web Servers.
Go to your Application registration on the Google Cast DSK Developer site. Edit your application details to be a "Styled Media Receiver", and leave the "Skin URL" blank. Edit the rest of the details accordingly. The name you supplied in the App registration details will show as the ChromeCast device connects to your app. And your app logo will appear in the place in the Chromecast UI that used to say "Default Media Receiver".
You must also make sure you have the following code:
public CastOptions getCastOptions(Context context) {
return new CastOptions.Builder()
.setReceiverApplicationId(context.getString("YOUR APPLICATION ID"))
.build();
}
And you must (of course) PUBLISH the changes you made to the Application Registration (or add your phone as a test device).

This is not currently possible. I have filed a feature request for this here: https://issuetracker.google.com/issues/156888250

Related

Playing sounds sequentially on android's google chrome (given the new restrictions on playing sound)

I have a small app that plays sequential sounds (a teaching app playing the sillables of a word)
This could be accomplished by firing an event right after each sound stopped playing. Something like:
var sounds = new Array(new Audio("1.mp3"), new Audio("2.mp3"));
var i = -1;
playSnd();
function playSnd() {
i++;
if (i == sounds.length) return;
sounds[i].addEventListener('ended', playSnd);
sounds[i].play();
}
(source)
However, now android chrome has implemented some new restrictions on how to play sound: Sound events must all be fired by a user action.
So, when I run code very similar to the above, the first sound plays, and then I get
Uncaught (in promise) DOMException: play() can only be initiated by a user gesture.
How can a sequence of sounds, determined at run time, be played on Android's Chrome?
To start with, Google Chrome on Android has been having the limitation of not allowing applications to play HTML audio(s) without an explicit action by the user. However, it is different than how stock browser(s), in most cases, handles it.
The reason, as Chromium Org puts it, is that, Autoplay is not honored on android as it will cost data usage.
You may find more details on the same here.
Apart from the fact that this results in wastage of bandwidth, this also makes some sense, since mobile devices are used in public and in houses, where unsolicited sound from random Web sites could be a nuisance.
However, in the later versions, this idea was over ruled and Chrome on Android started allowing autoplay of HTML audios and videos on it. Again after a set of reviews and discussions, this feature was reverted to what it was, making it mandatory for a user action to invoke HTML audios and videos on the Chrome for Android.
Here is something that I found more on the same. As it says, the reason stated was that "We're going to gather some data about how users react to autoplaying videos in order to decide whether to keep this restriction". And hence the playing option without a user action was reverted back.
You can also find more about the blocking of _autoplay of audio(s) and video(s) here on Forbes and The Verge.
However, this is something that I can suggest you to try which will help you achieve what you intend to. All you have to do is copy this code and paste in your Chrome for Android. This helps you reset the flag which is default set to not allowing to play HTML audios and videos without user interaction:
chrome://flags/#disable-gesture-requirement-for-media-playback
OR
about:flags/#disable-gesture-requirement-for-media-playback
If the above procedure doesn't help/work for you, you can do this:
Go into chrome://flags OR about:flags (this will direct you to chrome://flags) and Enable the "Disable gesture requirement for media playback" option (which is actually the same as the above URL specified).

How to tell if Intent was from Google Cast notification

I've setup casting abilities with the notification controls. The issue I'm having is that I need to differentiate between when a User clicks on the notification (that spawns the activity) and any other time the activity was created.
I would think this can be done by adding an intent-filter to the receiver entity in the manifest:
<receiver android:name=".services.CastIntentReceiver">
<intent-filter>
something goes here?
</intent-filter>
</receiver>
This is basically needed so I can rebuild the View where I house the Cast Controller after the activity is re-launched from the notification. Without any differentiation, the implementation interferes with the functionality I built for the View rebuilding after orientation change (since they both use onResume())
Thanks in advance for any help.
Try to read Media Route Provider. Media Route allows to play media content from their Android devices, allowing Android users to instantly show a picture, play a song or share a video.
The Android media router framework allows manufacturers to enable playback on their devices through a standardized interface called a MediaRouteProvider. A route provider defines a common interface for playing media on a receiver device, making it possible to play media on your equipment from any Android application that supports media routes.
A media route provider is distributed as part of an Android app. Your route provider can be made available to other apps by extending MediaRouteProviderService or wrapping your implementation of MediaRouteProvider with your own service and declaring an intent filter for the media route provider. These steps allow other apps to discover and make use of your media route.
There are two main types of playback supported by the media router framework. A media route provider can support one or both types of playback, depending on the capabilities of your playback equipment and the functionality you want to support:
Remote Playback — This approach uses the receiver device to handle the content data retrieval, decoding, and playback, while an Android device in the user's hand is used as a remote control. This approach is used by Android apps that support Google Cast.
Secondary Output — With this approach, the Android media application retrieves, renders and streams video or music directly to the receiver device. This approach is used to support Wireless Display output on Android.
<service android:name=".provider.SampleMediaRouteProviderService"
android:label="#string/sample_media_route_provider_service"
android:process=":mrp">
<intent-filter>
<action android:name="android.media.MediaRouteProviderService" />
</intent-filter>
</service>
public class SampleMediaRouteProviderService extends MediaRouteProviderService {
#Override
public MediaRouteProvider onCreateMediaRouteProvider() {
return new SampleMediaRouteProvider(this);
}
}

Google ChromeCast Playlist from Android Device

I'm using a sample app for the RemotePlaybackClient from #commonsware to play a video from a url to Google ChromeCast dongle, the app works like a charm but I would like to implement a playlist, any idea how to send a playlist to ChromeCast from an Android device?
As usual, I don't need code, just links, tutorials, etc... Tks.
Are you using a custom receiver?
If so, you can pass a json to such receiver with your playlist and manage that list with a playback state.
you might try looking at "mediaList" object here. Thats your playlist object.
This is a totally different project (not mediaRouter api but ccl instead) that i used because i wanted to implement a playlist and wanted to NOT take on my own receiver app. I wanted to see whether the default receiver could collaborate with an existing github sender sample - altered slightly to manipulate both a playList implemented in the "mediaList" AND to send appropriate and successive PLAY instructions to the default recieiver app when that app's state as relayed in normal "consumer" message traffic indicated state=ready.
D/ccl_VideoCastManager(31057): onApplicationStatusChanged() reached: Ready To Cast
So, when the default receiver fires the "ready" message, the senderApp can just call getNext to return an entry from "mediaList" and then send a "play(mediaInfo.entry)" to the default receiver.
onApplicationStatusChanged() is the interface used by the ccl to commmunicate/ sync player state between the local/remote players. When the default-remote-state changes to "ready to cast" you can use "VideoCastManager" and its base class to select the next MediaInfo entry and format a message for the remote to play it...
this.startCastControllerActivity(this.mContext, nextMediaInfo, 0, true);
code above from sender/ccl base tells the receiver to play the item that the sender has determine is next from list.
Note : i was advised to implement the playlist on a custom receiver app that i would write. Im not that ambitious and found a very simple hack on the sender/ccl classes that was reliable enough for me.

Casting video to ChromeCast by Youtube app

I tried using a Android phone to cast to Chromecast device by Youtube app. I added some Videos to queue, then I used another phone to cast to Chromecast device. The second one automatically knows the videos added to queue on the first one.
I don't know how Youtube app can do this?
EDIT I guess Youtube app uses one custom data channel besides Media channel. When Video is added to queue, sender app will send somethings (eg: videoId) to receiver. Receiver will save it in array of video ID. When another phone connects to Chromecast device, It'll receiver array of video ID from the receiver. Can anyone give other solutions? Thanks
I guess what you are asking is how you can create a play list, potentially shared by multiple devices. If that is the case, you have a couple of choices:
keep the playlist in the receiver: this is the simplest option. This will be a simple array on the receiver, kept in memory, which will go away when application ends. A custom receiver is required and it can implement the methods such as "append, insert, get, clear, ... to provide what the senders need. When each sender connects, it can ask (calling 'get' for example) for the current "queue" and then can modify the queue by other methods such as 'clear', 'append', 'insert', .... Note that there is no long-term persistence on the receiver (local storage is available but will be cleared as son as the app is gone).
keep the playlist in the cloud: you need to do most of the things that you do in the previous option but you also persist the playlist to the cloud; the advantage is that playlist lasts beyond the life of a session (this may or may not be desired). In addition, sender apps can potentially get the playlist fro the cloud directly, if needed.
The important thing is that the main storage for your playlist is not your sender devices; they don't know (and shouldn't know) abut the presence of other senders in the eco-system.
On the receiver side, we recently published a simple sample that sows how the notion of (local) playlist can be implemented; that is a simplified example but is enough to show that with minimal work, you can take advantage of the Media Channel; for more sophisticated handling of a shared queue, you definitely need an out-of-bound channel/namespace to handle all the additional api's that I mentioned above.

How to know if my Android SmartWatch extension is inactive?

I'm developing a RSS smart extension app using the Notification API.
I would like to know how to get the active/inactive status of my smart extension (the first checkbox when clicking on my RSS smart extension in the SmartWatch app).
The NotificationAPI sample uses an extra Checkbox preference to start or not a service downloading data generating notifications, but I don't want to force the user to go into a sub menu and activate the download of data. If the user activates my RSS smart extension, he already expects the extension to notify him if there's some new items into the RSS.
There's a callback to know when my smart extension is correctly added to liveware/smartwatch apps (onRegisterResult), but I didn't find the callback to know if the smart extension is actually active or not.
Thanks in advance!
The SampleNotificationExtension of the Smart Extension SDK has been provided to give some examples on:
how to add/update/remove/read data to/from the Notification database that resides in the Liveware Manager application (which is the hub of the Smart Extension API) through a content provider
how to respond to the event that the user opens a Notification on the SmartWatch and e.g. presses the action button
In the example extension, there is a service that is feeding the Notification database each 10 seconds, which is then shown on the SmartWatch device. The on/off setting in the preference activity is just for starting and stopping the loop that feeds the database.
Ok.
So I guess you want to subscribe to RSS feeds, and when new posts arrive, you want them to be propagated to the SmartWatch. You probably need start a service, like in the example, and you probably should have the service running as long as the watch is connected to the phone. This you can specify here:
#Override
protected boolean keepRunningWhenConnected() {
return true;
}
If you use the SmartExtension utility classes, your extension will automagically be registered and your service will be started. In the sample extension, after the extension has been registered, a check is done to see if the user has activated the extension via the preferences.
#Override
public void onRegisterResult(boolean result) {
/.../
boolean isActive = prefs.getBoolean(
getString(R.string.preference_key_is_active), false);
if (isActive) {
startAddData();
}
}
You could keep this if you want, but it is not required. As stated before, its just for starting and stopping the data feeding. Anyways, you could start a RSS check after registration.
If the user activates my RSS smart extension, he already expects the extension to notify him if there's some new items into the RSS.
When the service starts, you can check a delta between what is in the notification database, and what is fed from the RSS feed.
WELL, a long answer, hope it helps!

Categories

Resources