Electron Chromecast

An implementation of the chrome.cast API in electron
Usage
Basic
You must consume electron-chromecast from within your renderer process, preferably in a preload script.
require('electron-chromecast');
import 'electron-chromecast';
This will inject the chrome.cast variables and the associated methods globally automatically.
By default when requesting a new Session through chrome.cast.requestSession you will be provided an active Session with the first Chromecast Device we find. To change this behaviour read the Advanced section.
Advanced
var chromecast = require('electron-chromecast');
chromecast(function (receivers) {
return new Promise(function (resolve, reject) {
var chosenReceiver = receivers[0];
resolve(chosenReceiver);
});
});
import chromecast from 'electron-chromecast';
chromecast(async (receivers) => {
const chosenReceiver = receivers[0];
return chosenReceiver;
});
The function returned from electron-chromecast should be called with a single parameter; a function that returns a promise that will eventually resolve with a single receiver. This receiver is the one that will be used by chrome.cast.
Installation
Note: Behind the scenes we use MDNS which has some system requirements, make sure your system has the required dependencies.
TODO
TODO (But totally not needed): The chrome.cast.games API