Skip to content

Commit

Permalink
feat(castable-video): Add castCustomData to send arbitrary custom dat…
Browse files Browse the repository at this point in the history
…a to receiver app on load.
  • Loading branch information
cjpillsbury committed Aug 13, 2024
1 parent 33f0c67 commit 2b3d781
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/castable-video/castable-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const CastableMediaMixin = (superclass) =>

#localState = { paused: false };
#castOptions = getDefaultCastOptions();
#castCustomData;
#remote;

get remote() {
Expand Down Expand Up @@ -89,6 +90,7 @@ export const CastableMediaMixin = (superclass) =>
if (!this.#castPlayer) return super.load();

const mediaInfo = new chrome.cast.media.MediaInfo(this.castSrc, this.castContentType);
mediaInfo.customData = this.castCustomData;

// Manually add text tracks with a `src` attribute.
// M3U8's load text tracks in the receiver, handle these in the media loaded event.
Expand Down Expand Up @@ -221,6 +223,21 @@ export const CastableMediaMixin = (superclass) =>
this.setAttribute('cast-stream-type', `${val}`);
}

get castCustomData() {
return this.#castCustomData;
}

set castCustomData(val) {
console.log('setting castCustomData', val);
const valType = typeof val;
if (!['object', 'undefined'].includes(valType)) {
console.error(`castCustomData must be nullish or an object but value was of type ${valType}`);
return;
}

this.#castCustomData = val;
}

get readyState() {
if (this.#castPlayer) {
switch (this.#castPlayer.playerState) {
Expand Down

0 comments on commit 2b3d781

Please sign in to comment.