• Stars
    star
    638
  • Rank 70,537 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 10 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Chromecast client based on the new (CASTV2) protocol

castv2-client

A Chromecast client based on the new (CASTV2) protocol

This module implements a Chromecast client over the new (CASTV2) protocol. A sender app for the DefaultMediaReceiver application is provided, as well as an Application base class and implementations of the basic protocols (see the controllers directory) that should make implementing custom senders a breeze.

This implementation tries to stay close and true to the protocol. For details about protocol internals please see https://github.com/thibauts/node-castv2.

For advanced use, like using subtitles with the DefaultMediaReceiver check the wiki.

Installation

$ npm install castv2-client

On windows, to avoid native modules dependencies, use

$ npm install castv2-client --no-optional

Examples

###Launching a stream on the device

var Client                = require('castv2-client').Client;
var DefaultMediaReceiver  = require('castv2-client').DefaultMediaReceiver;
var mdns                  = require('mdns');

var browser = mdns.createBrowser(mdns.tcp('googlecast'));

browser.on('serviceUp', function(service) {
  console.log('found device "%s" at %s:%d', service.name, service.addresses[0], service.port);
  ondeviceup(service.addresses[0]);
  browser.stop();
});

browser.start();

function ondeviceup(host) {

  var client = new Client();

  client.connect(host, function() {
    console.log('connected, launching app ...');

    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: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/big_buck_bunny_1080p.mp4',
        contentType: 'video/mp4',
        streamType: 'BUFFERED', // or LIVE

        // Title and cover displayed while buffering
        metadata: {
          type: 0,
          metadataType: 0,
          title: "Big Buck Bunny", 
          images: [
            { url: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg' }
          ]
        }        
      };

      player.on('status', function(status) {
        console.log('status broadcast playerState=%s', status.playerState);
      });

      console.log('app "%s" launched, loading media %s ...', player.session.displayName, media.contentId);

      player.load(media, { autoplay: true }, function(err, status) {
        console.log('media loaded playerState=%s', status.playerState);

        // Seek to 2 minutes after 15 seconds playing.
        setTimeout(function() {
          player.seek(2*60, function(err, status) {
            //
          });
        }, 15000);

      });

    });
    
  });

  client.on('error', function(err) {
    console.log('Error: %s', err.message);
    client.close();
  });

}

###Other examples

Check the examples directory.

Contributors

  • xat (Simon Kusterer)
  • angelnu (Angel Nunez Mencias)

More Repositories

1

node-castv2

An implementation of the Chromecast CASTV2 protocol
JavaScript
758
star
2

b-spline

B-spline interpolation
JavaScript
287
star
3

node-upnp-mediarenderer-client

An UPnP/DLNA MediaRenderer client
JavaScript
121
star
4

node-google-search-scraper

Google search scraper with captcha solving support
JavaScript
82
star
5

duckduckgo

Simple duckduckgo results scraping
Python
65
star
6

pop-buffer

Progressive encoding for 3D meshes
JavaScript
59
star
7

styx

Simple, high-performance event streaming broker
Go
52
star
8

cubic-hermite-spline

Cubic Hermite spline interpolation
JavaScript
44
star
9

parse-cube-lut

Cube LUT (IRIDAS/Adobe) parser
JavaScript
34
star
10

rbf

Radial Basis Function (RBF) interpolation
JavaScript
32
star
11

apply-cube-lut

Apply a Cube (IRIDAS/Adobe) LUT to an image
JavaScript
31
star
12

node-upnp-device-client

A simple and versatile UPnP device client
JavaScript
31
star
13

node-rtmpdump

A streamable wrapper around the rtmpdump CLI
JavaScript
19
star
14

parse-wavefront-obj

Wavefront OBJ parser
JavaScript
18
star
15

t411

T411 API client
JavaScript
17
star
16

quantize-vertices

Quantizes vertices to any bit precision
JavaScript
14
star
17

bezier-curve

Bezier curve interpolation
JavaScript
13
star
18

merge-vertices

Merges mesh vertices having identical coordinates
JavaScript
10
star
19

parse-stl

STL (ASCII and binary) file parser
JavaScript
9
star
20

parse-3ds

Parses 3D Studio .3DS files
JavaScript
7
star
21

serialize-stl

STL (ASCII and binary) file serialization
JavaScript
7
star
22

node-sse-emitter

Server-Sent Events as simple as they can get
JavaScript
6
star
23

remove-orphan-vertices

Removes orphan vertices in a simplicial complex
JavaScript
6
star
24

serialize-wavefront-obj

Wavefront OBJ serializer
JavaScript
5
star
25

merge-meshes

Merges multiple meshes into one
JavaScript
5
star
26

vertices-bounding-box

Computes the bounding box of a set of vertices
JavaScript
4
star
27

rescale-vertices

Rescales vertices to the dimensions of a target bounding box
JavaScript
4
star
28

node-host-filtering-proxy

A straightforward host filtering HTTP proxy
JavaScript
4
star
29

ndarray-from-image

Extracts an image RGBA pixels as a ndarray
JavaScript
3
star
30

remove-degenerate-cells

Removes degenerate cells in a simplicial complex
JavaScript
3
star
31

serialize-stl-binary

STL binary serialization
JavaScript
3
star
32

node-generate-source-map

Generates an identity source-map from a javascript file
JavaScript
3
star
33

canvas-from-ndarray

Updates a canvas RGBA pixels from an ndarray
JavaScript
2
star
34

talk-react-bdxio

React.js et l'avenir de l'interface utilisateur HTML5
CSS
2
star
35

parse-stl-binary

STL binary parser
JavaScript
2
star
36

talk-react-bordeauxjs

Keep calm and React !
2
star
37

require

Experiments with module loading in the browser
JavaScript
1
star
38

react-starter

JavaScript
1
star
39

serialize-stl-ascii

STL ASCII serialization
JavaScript
1
star
40

talk-ansible-best

Ansible
JavaScript
1
star
41

eventemitter

Lightweight isomorphic event emitter
JavaScript
1
star
42

set-canvas-pixels

Sets a canvas pixels from an array of RGBA pixel values
JavaScript
1
star
43

get-canvas-pixels

Get an array of RGBA pixel values from a canvas
JavaScript
1
star
44

node-url-stream

Transforms a stream of URLs into a stream of their body content
JavaScript
1
star
45

router

Lightweight isomorphic router
JavaScript
1
star
46

ndarray-from-canvas

Extracts a canvas RGBA pixels as a ndarray
JavaScript
1
star
47

parse-stl-ascii

STL ASCII parser
JavaScript
1
star