Skip to content

wilcooo/fx_cast

 
 

Repository files navigation

Preview of cast device selection popup

fx_cast

A Firefox extension that implements the Chromecast API and exposes it to web apps to enable cast support. Communication with receiver devices is handled by a companion application (bridge).

Installing

Install the Firefox extension (from within Firefox) and bridge application via the installer packages. These are two separate downloads that can be found on the website or in the GitHub releases section.

The bridge application is currently supported on Windows, macOS and Linux.

Important: On Linux platforms such as Arch, it may be necessary to configure local hostname resolution1.

Installing via package managers

Note: These packages are maintained by third parties and support likely will not be provided for any issues specific to these packages.

Daemon Configuration

Daemon configuration (systemd)
  1. Create a new fx_cast user:
$ sudo useradd --system fx_cast
  1. Create a service file in /etc/systemd/system/fx_cast.service:
[Unit]
Description=fx_cast daemon

[Service]
User=fx_cast
ExecStart=/opt/fx_cast/fx_cast_bridge -d
Restart=always

[Install]
WantedBy=multi-user.target
  1. Enable the service:
$ sudo systemctl enable --now fx_cast

Usage

Clicking on the toolbar button or Cast... menu item in the page context menu will open a popup that shows a list of receiver devices will allow you to start casting the currently detected app2 or media.

Site Whitelist

The extension provides a whitelist for ensuring only trusted sites are allowed to load the cast API and communicate with receiver devices.

Sites may be added to the whitelist, either by clicking one of the whitelist options in the toolbar button context menu whilst visiting the site, or by manually entering a valid match pattern on the options page.

Whitelisted sites should then display a cast button as in Chrome, provided they're compatible with the extension/Firefox.

Building

Requirements

  • Node.js v16.x.x
  • Native build tools (see here)
  • Bonjour/Avahi (on Windows/Linux respectively)

Cross-compiling native dependencies may be possible, but isn't tested or supported. Build script options are provided for building/packaging on other platforms, but assume they won't work. Packaging on Linux for other Linux package formats should work fine.

Installing dependencies

Windows:

Debian / Ubuntu:

$ sudo apt install libavahi-compat-libdnssd-dev dpkg rpm

Runtime packages: avahi-daemon.

Fedora:

$ sudo dnf install avahi-compat-libdns_sd-devel dpkg rpm-build

Runtime packages: avahi, nss-mdns.

Arch Linux:

$ sudo pacman -S avahi dpkg rpm-tools

Instructions

$ git clone https://github.com/hensm/fx_cast.git
$ cd fx_cast
$ npm install
$ npm run build

# Install manifest for dist/ build. Installs to
# user-specific location and overrides a system-wide
# install. Call `remove-manifest` to restore previous state.
$ npm run install-manifest
$ npm run remove-manifest

This will build the ext and app, outputting to dist/:

  • dist/app/
    ... contains the built bridge with launcher script and manifest (with the path pointing that script). The install-manifest npm script copies this manifest to the proper location (or adds its current location to the registry on Windows).
  • dist/ext/
    ... contains the unpacked extension.

Watching ext changes:

$ npm run watch:ext

Launch Firefox with built extension (run in separate terminal):

$ npm run start:ext

32-bit on Windows

Building a 32-bit version is only supported for Windows. If you're building from a 64-bit system, you'll also need to rebuild any native dependencies as 32-bit.

$ npm clean-install --prefix ./app --arch=ia32  # If on a 64-bit system

# If building without packaging
$ npm run build:app -- -- --arch=x86 --usePkg

# If packaging
$ npm run package:app -- -- --arch=x86

Build scripts

Extension build script (build:ext) arguments:

  • --package
    Should package with web-ext.
  • --watch
    Should run webpack in watch mode.
  • --mirroringAppId "<appID>"
    Provide an alternative default mirroring receiver app ID.
  • --mode "production", "development"
    Run webpack in a different mode. Defaults to "development" unless combined with --package.

Bridge build script (build:app) arguments:

  • --usePkg
    Creates a single executable instead of a compiled JavaScript files and a launcher script.
  • --package
    Builds and creates installer packages for distribution.
  • --arch "x64","x86"
    Select platform arch to build for. Defaults to current platform arch.

Packaging

Build and package extension and bridge application for current platform:

$ npm run package
  • dist/app/
    ... contains the installer package: fx_cast_bridge-<version>-<arch>.(pkg|deb|rpm|exe)
  • dist/ext/
    ... contains the built extension archive: fx_cast-<version>.xpi.

Packaging examples:

$ npm run package:ext # Packaging extension
$ npm run package:app # Packaging bridge application

# Linux platforms
$ npm run package:app -- -- --packageType=deb
$ npm run package:app -- -- --packageType=rpm

Bridge package script arguments (includes the build script arguments):

  • --packageType "deb","rpm"
    Select the package type. Defaults to deb. Only relevant when building for Linux.

Testing

Testing requires geckodriver (or chromedriver for Chrome parity testing). See selenium-webdriver installation instructions (ignore npm install).

The test script expects a compatible installed bridge version and a packaged extension archive at dist/ext/.

Test results will be displayed in the terminal and within the opened browser tab. Chrome may take some time to initialize the media router component before the cast API is available for testing.

$ npm run build:app
$ npm run install-manifest
$ npm run package:ext
$ npm test

# Or if testing in Chrome
$ SELENIUM_BROWSER=chrome npm test

Video Demos

These are somewhat outdated now, but show the basic function of the extension:
fx_cast Netflix fx_cast HTML5

Credit

  • electron-chromecast3
  • Icons by icons8:
    • ext/src/ui/options/assets/icons8-cancel-120.png
    • ext/src/ui/options/assets/icons8-ok-120.png
    • ext/src/ui/options/assets/icons8-warn-120.png

Donations

PayPal

Donate with PayPal button Donate with PayPal

Footnotes

  1. By default, Arch does not configure Avahi to resolve .local hostnames via the name service switch (NSS), and the underlying mdns module used by this project relies on getaddrinfo to resolve these hostnames correctly.

  2. Some sites may only function properly when initiating casting from the in-page player buttons.

  3. Since it seems to be causing confusion, this project does not use electron. The electron-chromecast library was only used as a reference for the initial implementation of the API.

About

Google Cast implementation for Firefox

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 63.0%
  • JavaScript 20.0%
  • Svelte 10.9%
  • CSS 4.2%
  • NSIS 1.4%
  • HTML 0.4%
  • Shell 0.1%