diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a8bee7f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+.DS_Store
+node_modules/
+node_modules/*
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..e69de29
diff --git a/chromecast-play.html b/chromecast-play.html
new file mode 100644
index 0000000..04ac339
--- /dev/null
+++ b/chromecast-play.html
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/chromecast-play.js b/chromecast-play.js
new file mode 100644
index 0000000..a2ce338
--- /dev/null
+++ b/chromecast-play.js
@@ -0,0 +1,60 @@
+var Client = require('castv2-client').Client;
+var DefaultMediaReceiver = require('castv2-client').DefaultMediaReceiver;
+
+function play(host, url, type) {
+
+ var client = new Client();
+
+ client.connect(host, function() {
+ console.log('connected, launching app on %s with url %s and type %s', host, url, type);
+
+ client.launch(DefaultMediaReceiver, function(err, player) {
+ var media = {
+
+ // Here you can plug an URL to any mp4, webm, mp3 or jpg file with the proper contentType.
+ contentId: url,
+ contentType: type,
+ streamType: 'BUFFERED' // or LIVE
+ };
+
+ player.load(media, { autoplay: true }, function(err, status) {
+ console.log('media loaded playerState=%s', status.playerState);
+ client.close();
+ });
+
+ });
+
+ });
+}
+
+module.exports = function(RED) {
+ 'use strict';
+
+ function Node(n) {
+
+ RED.nodes.createNode(this,n);
+
+ var node = this;
+
+ this.on('input', function (msg) {
+
+ var creds = RED.nodes.getNode(n.creds),
+ payload = typeof msg.payload === 'object' ? msg.payload : {};
+
+ var attrs = ['ip', 'url', 'contentType'];
+ for (var attr of attrs) {
+ if (n[attr]) {
+ payload[attr] = n[attr];
+ }
+ }
+
+ if (payload.ip && payload.url && payload.contentType) {
+ play(payload.ip, payload.url, payload.contentType);
+ }
+
+ node.send(msg);
+ });
+ }
+
+ RED.nodes.registerType('chromecast-play', Node);
+};
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..2cd99fd
--- /dev/null
+++ b/package.json
@@ -0,0 +1,35 @@
+{
+ "name": "node-red-contrib-chromecast",
+ "version": "0.0.0",
+ "description": "NodeRED nodes to for Chromecast",
+ "main": "index.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1",
+ "predev": "npm i -g",
+ "dev": "node-red -v"
+ },
+ "author": "Stephen Keep",
+ "contributors": [
+ {
+ "name": "Stephen Keep",
+ "email": "stephenkeep@gmail.com"
+ }
+ ],
+ "keywords": [
+ "contrib-chromecast",
+ "chromecast"
+ ],
+ "license": "Apache-2.0",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/stephenkeep/node-red-contrib-chromecast"
+ },
+ "dependencies": {
+ "castv2-client": "^1.1.1"
+ },
+ "node-red": {
+ "nodes": {
+ "chromecast-play": "chromecast-play.js"
+ }
+ }
+}