aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-client/src/main.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-client/src/main.js')
-rw-r--r--packages/meshbay-client/src/main.js30
1 files changed, 16 insertions, 14 deletions
diff --git a/packages/meshbay-client/src/main.js b/packages/meshbay-client/src/main.js
index 1c371f5..a2a7a86 100644
--- a/packages/meshbay-client/src/main.js
+++ b/packages/meshbay-client/src/main.js
@@ -2333,29 +2333,31 @@ function registerBridge() {
handle('cast:devices', async () => castChromecast.devices());
- // One photo at a time, scaled and re-encoded by the page.
- handle('cast:image', async (_e, img) => {
- return castRelay.showImage({ bytes: Buffer.from(img.bytes), type: img.type });
- });
+ // A whole file for the receiver — a photo, a music track — in three steps,
+ // so that a large one never crosses in a single message.
+ handle('cast:file:begin', async (_e, f) => castRelay.beginFile(f || {}));
+ handle('cast:file:write', async (_e, data) => castRelay.writeFile(Buffer.from(data)));
+ handle('cast:file:end', async () => castRelay.endFile());
- // The relay's photo is loaded as a picture, anything else as the stream;
- // the page does not get to say which.
+ // The relay's file is loaded as what the relay says it is, anything else as
+ // the stream; the page does not get to say which.
const loadOf = (mediaUrl, subtitle) => (
- mediaUrl && mediaUrl === castRelay.imageUrl
- ? { subtitle: null, contentType: castRelay.imageType }
- : { subtitle: subtitle === undefined ? castRelay.subtitle : subtitle,
- contentType: 'video/mp4' });
+ mediaUrl && mediaUrl === castRelay.fileUrl
+ ? { subtitle: null, file: { contentType: castRelay.fileType, meta: castRelay.fileMeta } }
+ : { subtitle: subtitle === undefined ? castRelay.subtitle : subtitle, file: null });
- handle('cast:chromecast:connect', async (_e, { deviceId, mediaUrl, subtitle }) => {
+ handle('cast:chromecast:connect', async (_e, { deviceId, mediaUrl, subtitle, startAt }) => {
const l = loadOf(mediaUrl, subtitle);
- return castChromecast.connect(deviceId, mediaUrl, l.subtitle, l.contentType);
+ return castChromecast.connect(deviceId, mediaUrl, l.subtitle, l.file, l.file ? startAt : 0);
});
- handle('cast:chromecast:reload', async (_e, { mediaUrl, subtitle }) => {
+ handle('cast:chromecast:reload', async (_e, { mediaUrl, subtitle, startAt }) => {
const l = loadOf(mediaUrl, subtitle);
- return castChromecast.reload(mediaUrl, l.subtitle, l.contentType);
+ return castChromecast.reload(mediaUrl, l.subtitle, l.file, l.file ? startAt : 0);
});
+ handle('cast:chromecast:seek', async (_e, seconds) => castChromecast.seek(seconds));
+
// The player becomes a remote while casting: these drive the receiver.
handle('cast:chromecast:pause', async () => castChromecast.pause());
handle('cast:chromecast:play', async () => castChromecast.play());