我只找到了如何使用强制转换API获取sdk版本的方法。有没有办法检测接收器运行的是哪种型号的 chromecast?即。第一代?第二?超?
谢谢。
我创建了一个用于报告的自定义打字稿类。我们使用它来根据设备可以支持的内容准确检测用户正在使用的设备。这可能不适用于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;
}
}
没有名字,但你能猜到吗?
设备功能->IS_HDR_SUPPORTED = 较新的
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
否,没有 API 可以返回运行它的投射设备的型号或版本。
您可以在发送方检测模型名称 https://developers.google.com/android/reference/com/google/android/gms/cast/CastDevice.html#getModelName()"Chromecast","Chromecast Ultra"