Filter receiver list depending on capabilities in session request

This commit is contained in:
hensm
2022-04-25 16:01:10 +01:00
parent 4bccdecaa3
commit 234280f5ec
7 changed files with 67 additions and 25 deletions

View File

@@ -6,7 +6,7 @@ import { TypedEventTarget } from "../lib/TypedEventTarget";
import { Message, Port } from "../messaging";
import { ReceiverDevice, ReceiverDeviceCapabilities } from "../types";
import { ReceiverStatus } from "../cast/api/types";
import { ReceiverStatus } from "../cast/sdk/types";
interface EventMap {
receiverDeviceUp: { deviceInfo: ReceiverDevice };
@@ -84,16 +84,6 @@ export default new (class extends TypedEventTarget<EventMap> {
case "main:receiverDeviceUp": {
const { deviceId, deviceInfo } = message.data;
// TODO: Add proper support for Chromecast Audio devices
if (
!(
deviceInfo.capabilities &
ReceiverDeviceCapabilities.VIDEO_OUT
)
) {
break;
}
this.receiverDevices.set(deviceId, deviceInfo);
this.dispatchEvent(
new CustomEvent("receiverDeviceUp", {

View File

@@ -6,6 +6,7 @@ import options from "../../lib/options";
import { TypedEventTarget } from "../../lib/TypedEventTarget";
import { ReceiverDevice } from "../../types";
import { SessionRequest } from "../../cast/sdk/classes";
import {
ReceiverSelectionCast,
@@ -26,6 +27,7 @@ export interface PageInfo {
url: string;
tabId: number;
frameId: number;
sessionRequest?: SessionRequest;
}
/**

View File

@@ -4,6 +4,7 @@ import options from "../../lib/options";
import logger from "../../lib/logger";
import CastManager from "../../cast/CastManager";
import { SessionRequest } from "../../cast/sdk/classes";
import receiverDevices from "../receiverDevices";
import { getMediaTypesForPageUrl } from "../../lib/utils";
@@ -47,7 +48,10 @@ async function getSelector() {
async function getSelection(
contextTabId: number,
contextFrameId = 0,
selectionOpts?: { withMediaSender?: boolean }
selectionOpts?: {
sessionRequest: SessionRequest;
withMediaSender?: boolean;
}
): Promise<ReceiverSelection | null> {
return new Promise(async (resolve, reject) => {
let castInstance = CastManager.getInstance(
@@ -220,7 +224,8 @@ async function getSelection(
? {
url: pageUrl,
tabId: contextTabId,
frameId: contextFrameId
frameId: contextFrameId,
sessionRequest: selectionOpts?.sessionRequest
}
: undefined;