I'm trying to cast the videos playing on Jwplayer in near by devices like Tv, Laptop etc.
i followed this tutorial https://developer.jwplayer.com/jwplayer/docs/android-enable-casting-to-chromecast-devices
then on below code
CastOptions castOptions = new CastOptions.Builder()
// .setReceiverApplicationId(context.getString(R.string.app_id))
.setLaunchOptions(launchOptions)
.build();
I didn't get setReceiverApplicationId as i don't have such a id.
So, i went here How do you find your Google Cast App ID (app_id) in the 2017 Google Play Developer Console? and decided not to pay before testing.
Then on Jw docs it is mentioned setReceiverApplicationId() allows you to filter discovery results and to launch the receiver app when a cast session starts
Since i don't need filters i commented that line.
Now i got a cast icon on xml. but when I tap it nothing is happening.
Please someone tell me
Is app_id is necessary how to get it ?
How to test the chrome casting ?
You need to call setReceiverApplicationId, but you can use the default receiver ID without paying for a developer account.
For Android, your code should look like
CastOptions castOptions = new CastOptions.Builder()
.setReceiverApplicationId(CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID)
.setLaunchOptions(launchOptions)
.build();
Related
I am attempting to add Google Cast functionality to my audio apps. I have created a simple test app to figure it out. I have the cast button working, but currently, it is only displaying my TV's Chromecast and not the Nest Mini I also have on the network. I know this device is available on the network because it shows up as a cast option in YouTube Music. From reading the documentation on audio only devices, the only extra step I saw was to check the box next to "Supports casting to audio only devices" in my apps settings on Google Cast SDK Developer Console and to make sure I have the id set in my options provider. Here is my options provider:
class CastOptionsProvider: OptionsProvider {
override fun getCastOptions(context: Context): CastOptions {
return CastOptions.Builder()
.setReceiverApplicationId(context.getString(R.string.app_id))
.build()
}
override fun getAdditionalSessionProviders(context: Context): MutableList<SessionProvider> {
return mutableListOf()
}
It is defined in the manifest like this:
<meta-data
android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
android:value="com.example.casttest.CastOptionsProvider"/>
I am using the ID for my app from the Google Cast SDK site.
It looks like it just needed some time for the "Supports casting to audio only devices" to take effect. It took about 12 hour for it to start working.
I am trying to implement App invites in my app. Here's the java code that I am using :
Intent intent = new AppInviteInvitation.IntentBuilder(getString(R.string.invitation_title))
.build();
startActivityForResult(intent, Constants.REQUEST_CODE_INVITE);
But, as soon as I am clicking on the button which executes this code, a dialog pops up saying 'Unfortunately, Google Play Services has stopped'.
I have tried disabling, uninstalling and installing google play services again, and even restarting the phone, but no use.
No Exception is shown in android studio logs, so I am not able to figure out the problem is.
Please help.
There are a few issues here, and I'd also you to validate values.
getString requires resources. Assuming you are calling this from in an activity, you need to call
getResources().getString(R.....). You are likely getting null
returned which would result in an exception.
Although there is only 1 required parameter, you should fill out a few more to make sure you have a reasonable invitation, specifically setMessage(). Also, you can use setAccount() if you know the account, otherwise it will prompt.
I would also validate the input values. For example, log the string value you get for R.string.invitation_title to make sure you have set this correctly before you call the builder.
I was making a silly mistake which was leading to the error.
I was not initializing the GoogleApiClient before sending out the intent. Don't know how I missed it.
Here's the code that I was missing :
GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(AppInvite.API)
.enableAutoManage(this, this)
.build();
Hope it helps future visitors to this page.
I have a chromecast app with a custom receiver served through Google App Engine. My friend added my device and his to the Google Cast SDK Developer console.
As done in CastHelloText example app (https://github.com/googlecast/CastHelloText-android), I use the following snippet in my android app:
// configure cast device discovery
mMediaRouter = MediaRouter.getInstance(getApplicationContext());
mMediaRouteSelector = new MediaRouteSelector.Builder()
.addControlCategory(
CastMediaControlIntent.categoryForCast(getResources()
.getString(R.string.app_id))).build();
mMediaRouterCallback = new MyMediaRouterCallback();
Note:
I used my app_id that I got from developer console.
For some reasons, my friend is able to load the custom receiver using the Android app. But I am not able to do so. I have done the following with no help:
1) Restart the chrome cast device several times.
2) Factory reset the device.
My current firmware version: 27946
If I use the app_id from CastHelloText app, the same snippet works fine.
How do I confirm that my chrome cast device has loaded/aware of my custom receiver?
Make sure you have entered the correct serial number (from your device); it is often tricky to read that; take a photo and enlarge that. If problem persists, please contact our support.
I'm making a game that runs on the Chromecast. I'm stuck where I have to build a MediaRouteSelector. I'm not sure what control category I should use. When I use the code in the examples, the cast button doesn't show up (I do put the real application ID I got from the Dev Console):
mMediaRouteSelector = new MediaRouteSelector.Builder()
.addControlCategory(CastMediaControlIntent.categoryForCast("YOUR_APPLICATION_ID"))
.build();
The Chromecast icon shows up when I change the code to this, though:
mMediaRouteSelector = new MediaRouteSelector.Builder()
.addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)
.build();
There are two other categories I could use though, and I want to make sure I'm choosing the correct one.
MediaControlIntent.CATEGORY_LIVE_AUDIO
MediaControlIntent.CATEGORY_LIVE_VIDEO
Since you are building a game, you'd need to write a custom receiver and you'd need to register on the cast dev console to get an application id. That is the ID that should be put in for the "YOUR_APPLICATION_ID". If by doing that you do not see your chromecast, then it means you have not correctly done the registration steps for your device; serial number might have been entered incorrectly or the checkbox to send the serial number to Google may not have been checked.
I am trying to integrate google analytics with my android app. I followed the steps in the following link:
https://developers.google.com/analytics/devguides/collection/android/v3/#manifest
Then i tried the look at the statistic of my app, but it seems like analytics is not working, i must have done something wrong. The problem is, in those steps we do not make use of the tracking id, and in google analytic's web site, it says that
Download the Google Analytics SDK for Android or iOS and implement the tracking code,
including this tracking ID.
What does it mean to "implement the tracking id"? What should i do about this can anyone help me?
Thanks
Use this:
Tracker tracker = GoogleAnalytics.getInstance(context).getTracker(ga_trakingId);
Then you can SET some variables, that will be send to GoogleAnalytics:
tracker.set(Fields.APP_NAME, "Best Android Application");
tracker.set(Fields.APP_VERSION, "1.0");
To SEND some info, events:
tracker.send(MapBuilder.createEvent("UX", "App Launch", null, null).build());
You must watch Behind the Code: The Google Analytics v3 Mobile SDKs, all info from there.
Update 1
Google Analytics API v4 you should create google-services.json file from here and then you can use:
public Tracker getTracker() {
return GoogleAnalytics.getInstance(this).newTracker(R.xml.global_tracker);
}
And then you canuse it like this way:
getTracker().setScreenName("SomeScreenOrActivityName");
getTracker().send(new HitBuilders.ScreenViewBuilder().build()); // send screen name
The new process generates a file by Google which is called GoogleService-Info.plist.
This file contains (key, string) and one of them is:
<key>TRACKING_ID</key>
<string>*YOUR TRACKING ID*</string> // Auto generated by GAI
Just open the file and confirm that this is your tracking ID.