castable-video icon indicating copy to clipboard operation
castable-video copied to clipboard

Is it possible to make this work with audio?

Open samueldjack opened this issue 1 year ago • 2 comments

I'm trying to use the media-chrome library to build an audio player. I need to enable Chromecasting for my audio. Having delved through the source-code it appears the media-controller is building on this castable-video element for its chromecast behaviour.

Is there any way you can enhance castable-video to support audio elements too?

samueldjack avatar Aug 02 '23 14:08 samueldjack

thanks for the feedback! yes, that's a good idea. it's hard to put a ETA on this, it could take a while.

feel free to clone the repo and make a castable-audio element. edit: actually that might make it more difficult because we'd need to add those API's to Media Chrome too

Ideally we should rewrite this package with the remote playback API for both audio and video. https://github.com/muxinc/media-chrome/discussions/654

luwes avatar Aug 02 '23 18:08 luwes

this should now be quite easy to implement with something like:

import { CustomAudioElement } from 'custom-media-element';
import { CastableMediaMixin } from 'castable-video/castable-mixin.js';

export const CastableAudioElement = globalThis.document
  ? CastableMediaMixin(CustomAudioElement)
  : class {};

if (globalThis.customElements && !globalThis.customElements.get('castable-audio')) {
  globalThis.CastableAudioElement = CastableAudioElement;
  globalThis.customElements.define('castable-audio', CastableAudioElement);
}

luwes avatar Dec 07 '23 16:12 luwes