mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-09 17:19:59 +00:00
Add better support for handling device capabilities and receiver objects
This commit is contained in:
@@ -27,13 +27,15 @@ export default class Remote extends CastClient {
|
||||
|
||||
constructor(private host: string, private options?: CastRemoteOptions) {
|
||||
super();
|
||||
super.connect(host, {
|
||||
onReceiverMessage: message => {
|
||||
this.onReceiverMessage(message);
|
||||
}
|
||||
}).then(() => {
|
||||
this.sendReceiverMessage({ type: "GET_STATUS" });
|
||||
});
|
||||
super
|
||||
.connect(host, {
|
||||
onReceiverMessage: message => {
|
||||
this.onReceiverMessage(message);
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
this.sendReceiverMessage({ type: "GET_STATUS" });
|
||||
});
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
|
||||
@@ -16,6 +16,8 @@ interface CastRecord {
|
||||
md: string;
|
||||
// Friendly name (user-visible)
|
||||
fn: string;
|
||||
// Capabilities
|
||||
ca: string;
|
||||
// Version (?)
|
||||
ve: string;
|
||||
// Icon path (?)
|
||||
@@ -23,7 +25,6 @@ interface CastRecord {
|
||||
|
||||
cd: string;
|
||||
rm: string;
|
||||
ca: string;
|
||||
st: string;
|
||||
bs: string;
|
||||
nf: string;
|
||||
@@ -71,16 +72,18 @@ browser.on("serviceUp", service => {
|
||||
|
||||
const record = service.txtRecord as CastRecord;
|
||||
const device: ReceiverDevice = {
|
||||
id: record.id,
|
||||
friendlyName: record.fn,
|
||||
modelName: record.md,
|
||||
capabilities: parseInt(record.ca),
|
||||
host: service.addresses[0],
|
||||
port: service.port,
|
||||
id: service.name,
|
||||
friendlyName: record.fn
|
||||
port: service.port
|
||||
};
|
||||
|
||||
sendMessage({
|
||||
subject: "main:receiverDeviceUp",
|
||||
data: {
|
||||
deviceId: service.name,
|
||||
deviceId: device.id,
|
||||
deviceInfo: device
|
||||
}
|
||||
});
|
||||
|
||||
@@ -7,10 +7,21 @@ import {
|
||||
Volume
|
||||
} from "./components/cast/types";
|
||||
|
||||
export enum ReceiverDeviceCapabilities {
|
||||
NONE = 0,
|
||||
VIDEO_OUT = 1,
|
||||
VIDEO_IN = 2,
|
||||
AUDIO_OUT = 4,
|
||||
AUDIO_IN = 8,
|
||||
MULTIZONE_GROUP = 32
|
||||
}
|
||||
|
||||
export interface ReceiverDevice {
|
||||
host: string;
|
||||
friendlyName: string;
|
||||
id: string;
|
||||
friendlyName: string;
|
||||
modelName: string;
|
||||
capabilities: ReceiverDeviceCapabilities;
|
||||
host: string;
|
||||
port: number;
|
||||
status?: ReceiverStatus;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user