airplay icon indicating copy to clipboard operation
airplay copied to clipboard

Airplay plugins

Open elcuervo opened this issue 11 years ago • 9 comments

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?

elcuervo avatar Jan 23 '14 14:01 elcuervo

+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.

sodabrew avatar Jan 23 '14 15:01 sodabrew

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'

sodabrew avatar Jan 23 '14 17:01 sodabrew

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.

elcuervo avatar Jan 24 '14 01:01 elcuervo

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.

sodabrew avatar Jan 24 '14 01:01 sodabrew

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.

elcuervo avatar Jan 24 '14 01:01 elcuervo

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.

sodabrew avatar Jan 24 '14 01:01 sodabrew

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:

elcuervo avatar Jan 24 '14 01:01 elcuervo

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.

sodabrew avatar Jan 24 '14 01:01 sodabrew

:joy: Awesome. I love being in the same page!.

elcuervo avatar Jan 24 '14 01:01 elcuervo