Play Youtube Stream Sound on TimeSQuAir (Raspberry Pi)

Introduction: Play Youtube Stream Sound on TimeSQuAir (Raspberry Pi)

About: The ThingBox Project - A ready to flash Raspberry Pi image that contains Node-RED and Internet Of Things software for non developers.

You want to stream some music available on Youtube, and we understand you! Such a huge collection available for free! Follow this 5-minute recipe, and you'll be able to listen to your favorite songs!

First of all, here come the ingredient:

  • 1 TimeSquAir
  • 1 sound speaker

Let's start!

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: First, Two Small Technical Actions...

We need first to install appropriate softwares on the TimeSquAir to start. Don't worry, even if you're not comfortable with this, just follow what's written.

Open a SSH session (follow this instructable if you don't know how to do)

Install Python by typing the following command on the SSH window:
apt-get install python-pip

Install the LiveStreamer software by typing the following command:
pip install -U livestreamer

You're done with this step! You can close the SSH window

Step 2: Create the Dedicated Flow

Now we can build the flow responsible for reading youtube links.

Let's start with the node containing the Youtube URL.

Then a function putting this url in msg.url:
msg.url = msg.payload ;
return msg;

Let's put a command killing all the eventual running omxplayer jobs:
killall omxplayer.bin

Then, we build the command in a small function:
msg.payload = msg.url + " best --player \"omxplayer\" --fifo --yes-run-as-root " ;
return msg;

And finally, we launch livestreamer. Don't forget to "append msg.payload" in the command window (this will add the complete argument previously calculated to the livestreamer command)

Step 3: Some Youtube Links Might Cause an Error

Some youtube links might result in an error while trying to process livestreamer. In order to know what happens, we suggest to put some debug display nodes as shown on the picture.

Step 4: How to Stop the Stream?

In order to stop the ongoing audio stream, just put the following command, with the wanted launching method (here a simple Go Node):
killall omxplayer.bin

Step 5: Going Further

Know that you can play audio from youtube links, you can certainly improve the system. Examples:

  • Store your preferred youtube links
  • Use NFC tags to launch them, or stop the stream
  • Use NFC tags to increase / decrease the volume
  • Use this as an alarm clock by launching a youtube link at the desired time.
  • ...

Step 6: Learn More

Be the First to Share


    • Backyard Contest

      Backyard Contest
    • Silly Hats Speed Challenge

      Silly Hats Speed Challenge
    • Finish It Already Speed Challenge

      Finish It Already Speed Challenge