如何在接收器中检测Chromecast模式? [英] How to detect chromecast model in receiver?
本文介绍了如何在接收器中检测Chromecast模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只知道如何使用CAST API获取SDK版本。有没有办法检测接收器运行在哪种型号的Chromecast上?也就是说。第一代?第二?超级?
谢谢。
推荐答案
我创建了一个用于报告的自定义TypeScrip类。我们使用它来根据设备可以支持的内容来准确检测用户正在使用的设备。这可能不适用于Android电视。
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;
}
}
这篇关于如何在接收器中检测Chromecast模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文