user1165560
user1165560

Reputation: 341

How to detect chromecast model in receiver?

I only found how to get sdk version using cast api. Is there any way to detect which model of chromecast the receiver is running on? ie. First generation? Second? Ultra?

Thanks.

Upvotes: 1

Views: 3468

Answers (4)

Devin
Devin

Reputation: 41

I created a custom typescript class that we use for reporting. We use this to accurately detect what device a user is using based off what the devices can support. This may not work for Android TV.

private supported720PWidth = 1280;
private supported720PHeight = 720;
private supported1080PWidth = 1920;
private supported1080PHeight = 1080;
private supported2160PWidth = 3840;
private supported2160pHeight = 2160;
private mp4 = 'video/mp4';
private codecH264Lvl4Dot1 = 'avc1.640028';
private codecH264Lvl4Dot2 = 'avc1.64002A';
private firstGenLastSupportedOS = '1.36';
private codecH265 = 'hev1.1.6.L150.B0'
private context = CastReceiverContext.getInstance()



//https://developers.google.com/cast/docs/media#audio_passthrough we use codec because each device has a limitation so makes this as accurate as it can be
public isDeviceUltra(): boolean {
    return this.context.canDisplayType(this.mp4, this.codecH265, this.supported2160PWidth, this.supported2160pHeight, 30);
}

public isDevice3rdGen(): boolean {
    return this.context.canDisplayType(this.mp4, this.codecH264Lvl4Dot2, this.supported1080PWidth, this.supported1080PHeight, 60);
}

public isDevice2ndGen(): boolean {
    return this.context.canDisplayType(this.mp4, this.codecH264Lvl4Dot1, this.supported1080PWidth, this.supported1080PHeight, 30);
}

public isDevice1stGen(): boolean {
    return this.context.canDisplayType(this.mp4, this.codecH264Lvl4Dot1, this.supported1080PWidth, this.supported1080PHeight) && this.isOSLowerThanOrEqual(this.firstGenLastSupportedOS);
}

public isDeviceNestHub(): boolean {
    return this.context.canDisplayType(this.mp4, this.codecH264Lvl4Dot1, this.supported720PWidth, this.supported720PHeight, 60);
}

public isDeviceNestHubMax(): boolean {
    return this.context.canDisplayType(this.mp4, this.codecH264Lvl4Dot1, this.supported720PWidth, this.supported720PHeight, 30);
}

private getDevicesOSVersion(): string {
    let userAgent = navigator.userAgent.toString();
    let userAgentSplit = userAgent.split('/', 8);
    let fullOS = userAgentSplit[userAgentSplit.length - 1];
    return fullOS;
}

private isOSLowerThanOrEqual(expectedOS: string): boolean {
    let os = this.getDevicesOSVersion().split('.', 2);
    let expectedOSArray = expectedOS.split('.', 2);
    if (Number(os[1]) <= Number(expectedOSArray[1])) {
        return true;
    } else {
        return false;
    }
}

Upvotes: 4

Kristian
Kristian

Reputation: 2281

No names, but you can guess?

DeviceCapabilities->IS_HDR_SUPPORTED = a newer one

castReceiverManager = cast.receiver.CastReceiverManager.getInstance();
castReceiverManager.getDeviceCapabilities()
// gives: is_hdr_supported = false, on first generation

https://developers.google.com/cast/docs/reference/receiver/cast.receiver.CastReceiverManager#.DeviceCapabilities

Upvotes: 1

Tomas
Tomas

Reputation: 1

You can detect model name on sender side https://developers.google.com/android/reference/com/google/android/gms/cast/CastDevice.html#getModelName() "Chromecast","Chromecast Ultra"

Upvotes: 0

Ali Naddaf
Ali Naddaf

Reputation: 19094

No, there is no API to return the model or version of the cast device it is running on.

Upvotes: 0

Related Questions