airplay
airplay copied to clipboard
Airplay plugins
I was thinking about adding a plugin system for airplay
.
Something like:
Airplay.plugin Airplay::Youtube
Or something like that.
The idea is to allow a middleware stack to be executed. The plugins can implement their own play
and view
to allow operations like get the source youtube video or apply a filter to the image.
This could open the door for customizations in the flow and a prettier CLI
.
What do you guys think?
+1. Provides a place for useful non-core contributions to go.
Could distribute these in a third gem, airplay-plugins, from the same git repo.
Since Ruby modules and classes are open, the plugin can just register itself. Maybe provide media type and url hooks? I'm thinking of client code like this:
require 'airplay'
require 'airplay/plugins/youtube'
airplay.play 'youtube://youtubeurl'
I tend to hate automagic stuff but I have to say that this solutions seems pretty clean. My only concern is people forgetting about the custom protocol.
I'm not totally sold on the protocol part. There are times when that's a good indicator, like rtsp://
but in this case it's very contrived.
Yep. It's a tough call. Maybe leaving it like an explicit load is enough for now.
require "airplay"
module Airplay::Plugins::Youtube
def play(url, options = {})
# Fetches the mp4 version of the video
"correct_mp4_url"
end
end
Airplay.plugin Airplay::Plugins::Youtube
Airplay["Apple TV"].play("http://youtube.com...")
Or something like that.
Sure, but how does the plugin know to capture that call to play
and interpret it as youtube?
Maybe plugins get to register a play hook that can do a regex against the url?
If calling the plugin simply monkey-patched in a new version of play
I think that would be kind of ugly.
A middleware callstack. Every registered plugin that has a play
or view
method gets added to the stack.
So you can have something like this:
+---------------+ +---------------+ +--------------+
| Plugin A play | | Plugin B play | | Airplay play |
| method +--->| method +--->| method |
+---------------+ +---------------+ +--------------+
Again... thinking out loud here :smiley:
Yes, that's what I'm thinking, too! This would also solve the transcoding problem. A plugin could match on known-incompatible media urls, set up a transcode chain, and pass an IO handle or alternate local service port to the next in the stack.
:joy: Awesome. I love being in the same page!.