Over the past few months, I've been watching a lot more content on the TV, sat on the sofa, than at my desk like I used to. The bigger screen is much more enjoyable, not to mention it's a different seat to the one I work in 8 hours a day. Connected to the TV is an Amazon Fire TV Stick, which whilst not the best client device out there, works fine for my needs. As it's Android based, it's just using the normal YouTube android TV app, casted to from my phone.
However, for quite a few years now I've been watching all my YouTube through RSS, which means my account subscriptions are lacking. It's possible to use the TT-RSS app on my phone, open the YouTube videos in the YouTube app, then cast from there, but that's no fun. Given my laptop is in front of me anyway, it'd be great if I could cast from there instead.
It's possible to cast from Google Chrome / Chromium, but I'm a Firefox user, and I don't really want a second browser open just for YouTube (even though basically every desktop app nowadays is just a browser in disguise), even if it may be the best experience I can get right now. What I want is to be able to take a given YouTube video, and trivially throw it at my TV to watch there.
How hard can it be?
The Android Debug Bridge (
adb) is a development command-line tool to communicate with any android device over either USB or the network.
adb has to be enabled on the client, but once it is, you can pair with the device and transfer files, send events, install applications, or most importantly, trigger "Intents".
This isn't quite the place to talk about it, but "Intents" in android are basically a description of an operation to be performed. Apps can trigger "intents", which can be fulfilled by other apps. There are lots of intents built in to Android, and apps can define their own.
We can use
adb to trigger the
android.intent.action.VIEW intent, which is an incredibly generic intent designed to do the most sensible thing with the data provided. In our case, we can simply pass it a YouTube URL, and Android will try and open the URL, thus playing the video.
To get started, you'll first need to install
adb on your computer, and enable the developer tools on your android device - exactly how to do that will vary by device, but generally it's fairly simple. Once set up, run
abd connect <ip> with the IP address of the Android device, and follow any prompts. Then all you need to do is run:
adb shell am start -a android.intent.action.VIEW "https://www.youtube.com/watch?v=MvbAEEBLva8"
And suddenly, a video should start playing. The first time around, it'll probably prompt you to open in either the browser or YouTube native app, but so long as you select "Always" in the prompt, subsequent times will open the app by default.
If you'd rather not dive head first into developer APIs, there's a more polished solution (which really I'd recommend over
YouTube uses a protocol called DIAL (Discovery and Launch) developed by Netflix and Google which is designed to allow secondary devices (eg your phone or computer) to discovery and launch content on larger devices (eg your TV). The YouTube app uses this for the "Play on TV" functionality to find, pair and cast content to another device. The protocol is free, well documented, and has some reference implementations.
ytcast is a DIAL client command-line tool which allows pairing with DIAL-compatible displays and casting YouTube URLs. The project's README has a very interesting section on how it works.
The pairing process is much simpler than
ytcast -s will "search" for available devices on the network, then to launch a video, just run:
ytcast -d my_tv "https://www.youtube.com/watch?v=MvbAEEBLva8"
Next time around, you can omit the
-d argument, as
ytcast will assume you want to cast to the same device. Useful if you're lazy, but also have multiple devices (say living room and bedroom). For casting, this is about as good as I'm going to get, until something can be better integrated into the browser.
A very honourable mention, but sadly not applicable for me.
fx_cast is a Firefox extension which enables casting certain websites to Chromecasts. Sadly, and fairly obviously, that doesn't work for Android TVs like my Fire TV. There's an issue that's been open for a while to add DIAL support. If that ever gets implemented, it goes from being slightly useful if I ever come across a chromecast to the absolute perfect experience for me and I suspect so many others. I really look forward to see that get implemented, but sadly there aren't many good signs it's going to happen any time soon.
Fear not, if that ever comes into fruition, you'll hear me singing its praises!
Share this page