diff --git a/plugins/chromecast/package-lock.json b/plugins/chromecast/package-lock.json index 02e48b9f6..6e7cc2af6 100644 --- a/plugins/chromecast/package-lock.json +++ b/plugins/chromecast/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/chromecast", - "version": "0.1.43", + "version": "0.1.45", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@scrypted/chromecast", - "version": "0.1.43", + "version": "0.1.45", "license": "Apache-2.0", "dependencies": { "@scrypted/common": "file:../../common", diff --git a/plugins/chromecast/package.json b/plugins/chromecast/package.json index 793cc3b00..df29b4a97 100644 --- a/plugins/chromecast/package.json +++ b/plugins/chromecast/package.json @@ -1,6 +1,6 @@ { "name": "@scrypted/chromecast", - "version": "0.1.43", + "version": "0.1.45", "description": "Send video, audio, and text to speech notifications to Chromecast and Google Home devices", "author": "Scrypted", "license": "Apache-2.0", diff --git a/plugins/chromecast/src/main.ts b/plugins/chromecast/src/main.ts index 57c3255c7..21a70a060 100644 --- a/plugins/chromecast/src/main.ts +++ b/plugins/chromecast/src/main.ts @@ -156,29 +156,27 @@ class CastDevice extends ScryptedDeviceBase implements MediaPlayer, Refresh, Eng // image Direct convert // video Direct RTC - // check to see if this is url friendly media. + + // convert this into a chromecast friendly url, or a media object that must be streamed. if (typeof media === 'string') { - if (media.startsWith('http')) { - url = media; - } - else if (options?.mimeType?.startsWith('image/')) { + // always fetch images up front. + if (options?.mimeType?.startsWith('image/')) { const mo = await mediaManager.createMediaObjectFromUrl(media, options?.mimeType); url = await mediaManager.convertMediaObjectToInsecureLocalUrl(mo, options?.mimeType); } + else if (media.startsWith('http')) { + // eh might not work, but whatever. + url = media; + } + else { + media = await mediaManager.createMediaObjectFromUrl(media, options?.mimeType); + } } - else { - try { - url = media.mimeType === ScryptedMimeTypes.InsecureLocalUrl || media.mimeType === ScryptedMimeTypes.LocalUrl - ? await mediaManager.convertMediaObjectToInsecureLocalUrl(media, media.mimeType) - : await mediaManager.convertMediaObjectToUrl(media, media.mimeType); - urlMimeType = media.mimeType; - } - catch (e) { - this.console.error('url conversion failed, falling back'); - } + else if (options?.mimeType?.startsWith('image/')) { + url = await mediaManager.convertMediaObjectToInsecureLocalUrl(media, options?.mimeType); } - if (url?.startsWith('http')) { + if (url) { this.sendMediaToClient(options && (options as any).title, url, // prefer the provided mime type hint, otherwise infer from url.