Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fork request] Would it be possible to distribute a small subset of this functionality compiled to WebAssembly? #193

Open
warren-bank opened this issue Oct 3, 2024 · 3 comments

Comments

@warren-bank
Copy link

The reason for my asking is that Firefox desktop doesn't support Chromecast.
Presumably, this is also the case for all non-Chromium browsers.
If the following (example) API could be run from a WebExtension..
then it would be easy to write a very capable replacement for Chrome's built-in integration.

window.GoChromecast.status(ip)
  => {"status": "Idle", "volume": 0.17, "muted": false}

window.GoChromecast.load(ip, url)
window.GoChromecast.pause(ip)
window.GoChromecast.unpause(ip)
window.GoChromecast.next(ip)
window.GoChromecast.previous(ip)
window.GoChromecast.rewind(ip, seconds)
window.GoChromecast.seek(ip, seconds)
window.GoChromecast.mute(ip)
window.GoChromecast.unmute(ip)
window.GoChromecast.volume(ip, level)
  => true

Note that because there is currently no browser API to use mDNS discovery,
a static (stateless) "ip" parameter is explicitly passed to each method.

These methods would be equivalent to the following functionality,
which is already available from the command-line:

ip='192.168.0.156'
url='https://example.com/path/to/media.mp4'
seconds='30'
level='0.55'

go-chromecast -a "$ip" status
  Idle, volume=0.17 muted=false

go-chromecast -a "$ip" load "$url"

go-chromecast -a "$ip" pause
go-chromecast -a "$ip" unpause

go-chromecast -a "$ip" next
go-chromecast -a "$ip" previous

go-chromecast -a "$ip" rewind "$seconds"
go-chromecast -a "$ip" seek "$seconds"

go-chromecast -a "$ip" mute
go-chromecast -a "$ip" unmute
go-chromecast -a "$ip" volume "$level"
@vishen
Copy link
Owner

vishen commented Oct 13, 2024

I quite like this idea. I don't know much about WASM and using it with Go, but this seems like something that could be possible.

@warren-bank
Copy link
Author

Actually, I made a bad assumption. I thought that WebAssembly would support TCP sockets, which client-side javascript does not. But I was wrong.

As such, there's no advantage in going down the rabbit hole that I proposed.. and all of the work that it would involve. There are already javascript libraries that could be used, with the assistance of a proxy to bridge between websockets (from the browser) and tcp sockets (to the chromecast). After commenting here, I actually played around with some and made working browser builds:

  1. browser-castv2
  2. browser-castv2-client
  3. browser-chromecast-player

@warren-bank
Copy link
Author

I should also note that fx_cast, which is the currently accepted workaround for casting from Firefox, requires using a native "bridge" application for this same purpose. This app allows the addon to use mDNS for device discovery and TCP sockets for communication, neither of which can be done by client-side javascript from within the addon using the APIs provided by the browser.

Unfortunately, it doesn't seem that WebAssembly provides any additional capabilities.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants