This Arduino sketch allows you to control media playing on a ChromeCast device.
The sketch can control all the existing Google apps that support ChromeCast including YouTube, Google Music and Google Movies. Netflix is not supported since it uses a proprietary protocol for media control.
The sketch requires this websocket library which has to be installed in the libraries directory of your Arduino IDE. The websocket library has been modified to work with ChromeCast devices. Use the Arduino IDE to upload the code onto an Arduino device.
To customize the sketch for your ChromeCast device, simply update ChromeCast device IP address in the sketch. The sketch assumes a button is on pin A0. Uncomment the loop() code if you want to use pin 2 for the button. You can also put a LED on pin 7 to get feedback when the network is initialized and the button is pressed.
To control playback, the sketch makes a websocket connection to the current app running on the ChromeCast device. These steps are done in order:
- Check if there is an app running on the ChromeCast device and get its app id.
- Get the app status to get the connection service URL.
- Use the connection service URL to get the websocket address.
- Create a websocket connection.
- Send RAMP PLAY/STOP messages to control media playback.
- Close the websocket connection.
Watch this video to see the sketch in action.
Other apps developed by Entertailion:
- ChromeCast-Arduino: Use an Arduino to send YouTube videos to a ChromeCast device when a motion sensor is triggered
- Fling: Share local media files with a ChromeCast device
- Able Remote for Google TV: The ultimate Google TV remote
- Open Launcher for Google TV: The ultimate Google TV launcher
- Overlay for Google TV: Live TV effects for Google TV
- Overlay News for Google TV: News headlines over live TV
- Video Wall: Wall-to-Wall Youtube videos
- GTV Tasker Plugin: Control your Google TV with Tasker actions