All Projects → alxhotel → chromecast-api

alxhotel / chromecast-api

Licence: MIT License
📺 Chromecast Node.js module

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to chromecast-api

Rapidbay
Self-hosted torrent video streaming service compatible with Chromecast and AppleTV deployable in the cloud
Stars: ✭ 163 (+33.61%)
Mutual labels:  stream, chromecast, subtitles
vlitejs
🦋 vLitejs is a fast and lightweight Javascript library for customizing video and audio player in Javascript with a minimalist theme (HTML5, Youtube, Vimeo, Dailymotion)
Stars: ✭ 162 (+32.79%)
Mutual labels:  chromecast, subtitle, cast
Subtitle.js
Stream-based library for parsing and manipulating subtitle files
Stars: ✭ 234 (+91.8%)
Mutual labels:  stream, subtitles, subtitle
playercast
Cast to media player and control playback remotely.
Stars: ✭ 46 (-62.3%)
Mutual labels:  streaming, stream, cast
Gnome Shell Extension Cast To Tv
Cast files to Chromecast, web browser or media player app over local network.
Stars: ✭ 200 (+63.93%)
Mutual labels:  streaming, stream, chromecast
pysub-parser
Library for extracting text and timestamps from multiple subtitle files (.ass, .ssa, .srt, .sub, .txt).
Stars: ✭ 40 (-67.21%)
Mutual labels:  subtitles, subtitle
casita
A macOS menubar app to control media playing on your Google Cast enabled devices. 🏡
Stars: ✭ 22 (-81.97%)
Mutual labels:  chromecast, cast
cast-web-api
Quick and dirty web API for Google Cast enabled devices.
Stars: ✭ 126 (+3.28%)
Mutual labels:  chromecast, chromecast-api
android-cast-remote-display-sample
📻 Google Cast's Remote Display Sample for Android
Stars: ✭ 38 (-68.85%)
Mutual labels:  chromecast, cast
punchtop
A power hour written in rust with Chromecast support
Stars: ✭ 26 (-78.69%)
Mutual labels:  chromecast, cast
srtmerger
subtitle merger is a tool for merging two or more subtitles for videos.
Stars: ✭ 35 (-71.31%)
Mutual labels:  subtitles, subtitle
canvas-cast
Cast any <canvas> element to an LED Matrix over WebSockets with an Arduino/ESP8266.
Stars: ✭ 39 (-68.03%)
Mutual labels:  stream, cast
subtitleeditor
Subtitle Editor is a GTK+3 tool to create or edit subtitles for GNU/Linux/*BSD.
Stars: ✭ 79 (-35.25%)
Mutual labels:  subtitles, subtitle
chromecast-mqtt-connector
Make your Chromecast devices discoverable and controllable via MQTT.
Stars: ✭ 40 (-67.21%)
Mutual labels:  chromecast, cast
matroska-subtitles
💬 Streaming parser for embedded .mkv subtitles.
Stars: ✭ 40 (-67.21%)
Mutual labels:  stream, subtitles
PersianSubtitleFixer
Fix Arabic and Persian subtitles by converting them into UTF-8
Stars: ✭ 25 (-79.51%)
Mutual labels:  subtitles, subtitle
moestreamer
macOS menubar music player
Stars: ✭ 17 (-86.07%)
Mutual labels:  streaming, stream
twitchpipe
Pipe your favorite Twitch streams to the media player of your choice, or a file to save them for later. Supports low-latency playback.
Stars: ✭ 28 (-77.05%)
Mutual labels:  streaming, stream
TLightFileStream
Implements a lightweight, high-performance, non-allocating advanced-record-based wrapper around the SysUtils file handling routines as an alternative to Classes.TFileStream.
Stars: ✭ 21 (-82.79%)
Mutual labels:  streaming, stream
Tributary
Streaming reactive and dataflow graphs in Python
Stars: ✭ 231 (+89.34%)
Mutual labels:  streaming, stream

chromecast-api

NPM Version Build Status Dependency Status Standard - Javascript Style Guide

chromecast-api is a NodeJS module to play any content in your Chromecast device.

Installation

npm install chromecast-api 

Usage

const ChromecastAPI = require('chromecast-api')

const client = new ChromecastAPI()

client.on('device', function (device) {
  var mediaURL = 'http://commondatastorage.googleapis.com/gtv-videos-bucket/big_buck_bunny_1080p.mp4';

  device.play(mediaURL, function (err) {
    if (!err) console.log('Playing in your chromecast')
  })
})

Supported Apps

  • Media (video and audio)
  • Youtube videos

Subtitles and Cover

To include subtitles and a cover image, use an Object instead of a string in the function play(mediaObject):

Note: your subtitles must implement CORS.

const ChromecastAPI = require('chromecast-api')

const media = {
  url : 'http://commondatastorage.googleapis.com/gtv-videos-bucket/big_buck_bunny_1080p.mp4',
  subtitles: [
    {
      language: 'en-US',
      url: 'https://raw.githubusercontent.com/alxhotel/chromecast-api/master/test/captions_styled.vtt',
      name: 'English',
    },
    {
      language: 'es-ES',
      url: 'https://raw.githubusercontent.com/alxhotel/chromecast-api/master/test/captions_styled_es.vtt',
      name: 'Spanish',
    }
  ],
  cover: {
    title: 'Big Bug Bunny',
    url: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg'
  },
  subtitles_style: {
    backgroundColor: '#FFFFFF00', // see http://dev.w3.org/csswg/css-color/#hex-notation
    foregroundColor: '#FFFFFFFF', // see http://dev.w3.org/csswg/css-color/#hex-notation
    edgeType: 'OUTLINE', // can be: "NONE", "OUTLINE", "DROP_SHADOW", "RAISED", "DEPRESSED"
    edgeColor: '#000000FF', // see http://dev.w3.org/csswg/css-color/#hex-notation
    fontScale: 1.2, // transforms into "font-size: " + (fontScale*100) +"%"
    fontStyle: 'BOLD', // can be: "NORMAL", "BOLD", "BOLD_ITALIC", "ITALIC",
    fontFamily: 'Droid Sans',
    fontGenericFamily: 'SANS_SERIF', // can be: "SANS_SERIF", "MONOSPACED_SANS_SERIF", "SERIF", "MONOSPACED_SERIF", "CASUAL", "CURSIVE", "SMALL_CAPITALS",
    //windowColor: '#AA00FFFF', // see http://dev.w3.org/csswg/css-color/#hex-notation
    //windowRoundedCornerRadius: 10, // radius in px
    //windowType: 'ROUNDED_CORNERS' // can be: "NONE", "NORMAL", "ROUNDED_CORNERS"
  }
}

const client = new ChromecastAPI()

client.on('device', function (device) {
  device.play(media, function (err) {
    if (!err) console.log('Playing in your chromecast')
  })
})

API

const client = new ChromecastAPI()

Initialize the client to start searching for chromecast devices.

client.on('device', callback)

Listen for new devices by passing callback(device) in the callback parameter.

With the Device object you can now interact with your Chromecast.

This is an example of the attributes of device:

{
  name: 'Chromecast-e363e7-3e23e2e-3e2e-23e34e._googlecast._tcp.local', // Unique identifier
  friendlyName: 'Bobby', // The name you gave to your chromecast
  host: '192.168.1.10' // Local IP address
}

client.devices[...]

An array of all devices found by the client.

client.update()

Trigger the mDNS and SSDP search again. Warning: the device event will trigger again (it might return the same device).

device.play(mediaURL [, opts], callback)

Use this function to play any media in the chromecast device. Make sure mediaURL is accessible by the chromecast.

Pass an attribute startTime in the opts object to set where to start an audio or video content (in seconds).

{
  startTime: 120 // Start the content at the 2 minute mark
}

device.pause(callback)

Pause the media.

device.resume(callback)

Resume the media.

device.stop(callback)

Stop playing the media.

device.seek(seconds, callback)

Seek forward seconds in time.

device.seekTo(specificTime, callback)

Seek to the specificTime in seconds.

device.setVolume(level, callback)

Set the volume to a specific level (from 0.0 to 1.0).

device.changeSubtitles(index, callback)

Change the subtitles by passing the index of the subtitle you want based on the list you passed before.

device.changeSubtitlesSize(fontSize, callback)

Choose the subtitles font size with fontSize. The default is 1.0.

device.subtitlesOff(callback)

Turn the subtitles off.

device.getCurrentTime(callback)

Get the current time of the media playing (in seconds). It's a shortcut for getting the currentTime from the status.

device.close(callback)

Close the connection with the device.

device.on('connected', callback)

Event emitted when the client is connected to the device.

device.on('finished', callback)

Event emitted when the media (audio or video) has finished.

device.on('status', callback)

Event emitted when the device has a new status: callback(status).

Additional information

License

MIT. Copyright (c) Alex

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].