我只找到了如何使用cast api获取sdk版本。有没有办法检测接收器运行的chromecast模型?即。第一代?第二?超?
感谢。
答案 0 :(得分:2)
我创建了一个自定义的打字稿类,用于报告。我们使用它来根据设备可以支持的内容准确检测用户正在使用的设备。这可能不适用于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;
}
}
答案 1 :(得分:1)
没有名字,但是你可以猜到吗?
DeviceCapabilities-> IS_HDR_SUPPORTED =较新的
castReceiverManager = cast.receiver.CastReceiverManager.getInstance();
castReceiverManager.getDeviceCapabilities()
// gives: is_hdr_supported = false, on first generation
答案 2 :(得分:0)
不,没有API可以返回运行它的模型或版本。
答案 3 :(得分:0)
您可以检测发件人方https://developers.google.com/android/reference/com/google/android/gms/cast/CastDevice.html#getModelName()的型号名称 &#34; Chromecast&#34;,&#34; Chromecast Ultra&#34;