GithubHelp home page GithubHelp logo

andrasbiro / arducastcontrol Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 8.0 27 KB

Chromecast control library for arduino/platformio

License: MIT License

C++ 48.65% C 51.35%
arduino-library arduino platformio platformio-arduino chromecast chromecast-audio chromecast-api

arducastcontrol's Introduction

ArduCastControl

Chromecast control library for platformio/arduino. It supports requesting some information of the casting (e.g. artist and title), as well as a minimal control (pause, previous, next, seek and volume).

Dependencies

The library depends on ArduinoJson and nanopb. This is already set for platformio.

It has a significant RAM footprint, which is usually not an issue for wifi capable boards. It was only tested on ESP8266.

References

Flow of connection

Understanding how the CASTV2/chromecast protocols work took me a while, so here's a quick summary on what this library does.

  1. TCP/TLS connection is opened to the device. Self-signed certificates are sufficient
  2. An application layer connection to the device itself ("receiver-0") is established
  3. Status is requested from the device with GET_STATUS messages on the receiver namespace
    1. Reported status include volume information
  4. When something casts to the device, chromecast reports an application is running with a sessionId
  5. An application layer connection to the application (sessionid) is established
  6. Status is requested from the application with GET_STATUS messages on the media namespace
    1. Reported status includes all sort of information of the currently playing track
    2. As well as a mediaSessionId, which is changed with every track change
  7. Control messages can be sent to the application on the media namespace using a specified mediaSessionId

Useful values saved

All of the following are public fields of the class, which are updated when the class' loop() function is called on a given status.

  • volume - The volume set on the device, between 0 and 1
  • isMuted - True if the device is muted
  • displayName - Typically the application casting, like "Spotify"
  • statusText - A short status, e.g. "Casting: Whole Lotta Love"
  • playerState - State of playback, e.g. "PLAYING"
  • title - Title of the current song, e.g. "Whole Lotta Love"
  • artist - Artist of the current song, e.g. "Led Zeppelin"
  • duration - Duration of the current song in seconds, e.g. 333.89
  • currentTime - Current time in the song in seconds, e.g. 2.27

This list can be easily extended by saving more when processing MEDIA_STATUS or RECEIVER_STATUS.

Control methods

The following controls are accessible as methods in the class:

  • play() - Plays (resumes) the current song
  • pause() - Pauses/Resumes the current song
  • prev() - Previous track
  • next() - Next track
  • seek() - Seeks in song
  • setVolume() - Volume control
  • setMute() - Mute control

I think this covers all possible controls except casting and playlist features. However, extending it should be fairly easy, using the play() or setVolume() method as a template (for media/device commands respectively)

Further documentation

For further documentation, please refer to the comments in ArduCastControl.h and the example, which demonstrates the main features.

Further developement

Don't expect any new features/bugfixes, as I'm quite happy with the featureset as is. However, I do accept pull requests.

arducastcontrol's People

Contributors

andrasbiro avatar borisvl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

arducastcontrol's Issues

problem after arduinoJson Update

Hello,

just to share I had issue with new ArduinoJson library to compile (V6.20).

I solved it by replacing in ArduCastControl.cpp
as<char*>
by
as<const char*>

Now it compile, I need to test to confirm

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.