GithubHelp home page GithubHelp logo

thecapypara / castv2-device-monitor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mattiash/castv2-device-monitor

0.0 1.0 0.0 31 KB

Monitor a castv2 (a.k.a Chromecast) device

JavaScript 3.70% TypeScript 96.30%

castv2-device-monitor's Introduction

castv2-device-monitor

Monitor the state of a castv2 (a.k.a. Chromecast) device.

Usage

const DeviceMonitor = require('castv2-device-monitor).DeviceMonitor

// Monitor the chromecast with the friendly name Livingroom
let dm = new DeviceMonitor('Livingroom')
dm.on('powerState', powerState => console.log('powerState', powerState))
dm.on('playState', playState => console.log('playState', playState))
dm.on('application', application => console.log('application', application))
dm.on('media', media => console.log('media', media))

A DeviceMonitor monitors a single Chromecast device and emits events whenever something changes with it. It can emit the following events:

event 'powerState'

The powerState event has a single parameter with the possible values 'on' and 'off'. A DeviceMonitor will always emit a powerState event soon after it is created.

As far as I know, a Chromecast device does not expose any real power indicator. The powerState is an attempt to emulate a power indicator. powerState will always be on when the Chromecast is playing something, and it will be set to off after the Chromecast has been idle for 60 seconds. To use another idle timeout, supply the timeout in milliseconds as the third parameter to the DeviceMonitor contructor.

The powerState can be used to control power to an amplifier or TV that the Chromecast is connected to.

event 'playState'

The playState event has a single parameter with the possible values 'play' and 'pause'.

event 'application'

The application event has a single parameter that is the friendly name of the application that is currently controlling the Chromecast.

event 'media'

The media event has a single parameter that contains an object with properties 'artist' and 'title'. These describe the currently playing song on the Chromecast.

event 'volume'

The volume event has a single parameter that contains the current volume as a number between 0-1, where 0 is muted and 1 is the maximum volume.

Controlling device

The DeviceMonitor also offers a limited ability to control playback on the device:

dm.pauseDevice()
dm.playDevice()
dm.volumeUp()
dm.volumeDown()

Additionally, dm.stopDevice() can be used to stop the session from the application to the device. It usually means that you have to select the cast-device again from the application.

Debugging

This module includes a binary castv2-device-monitor for testing purposes.

Usage:

./node_modules/.bin/castv2-device-monitor Livingroom

DEBUG=* ./node_modules/.bin/castv2-device-monitor Livingroom eth0 5000

castv2-device-monitor's People

Contributors

mattiash avatar stormtony avatar thecapypara avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.