1

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.

user1165560
  • 331
  • 4
  • 21

4 Answers4

3

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;
    }
}
Devin
  • 31
  • 3
1

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

Kristian
  • 2,071
  • 23
  • 15
0

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

Ali Naddaf
  • 16,951
  • 2
  • 21
  • 28
  • 2
    Why is this? How can I identify that I am running on an Ultra for example, so I can start an HEVC stream in 4K? Also for example Sony Android TVs do not play high framerate content like they should. – Nioreh May 08 '17 at 16:17
  • I'm also curious to know if there's a reason for this? Is this something Google is trying to prohibit? Is there any other API that can be used to guess the version? – Jean-François Savard Sep 28 '18 at 14:24
0

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"

Tomas
  • 1
  • 1
    Welcome to StackOverflow! If you can provide more details, explanation, and/or example code you will improve your chances of helping the asker and gain [reputation](https://stackoverflow.com/help/whats-reputation). – Daniel Bickler Jul 12 '17 at 14:10
  • That's only for Android – Steve Apr 12 '23 at 02:38