Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Airplay plugins #73

Open
elcuervo opened this issue Jan 23, 2014 · 9 comments
Open

Airplay plugins #73

elcuervo opened this issue Jan 23, 2014 · 9 comments

Comments

@elcuervo
Copy link
Owner

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?

@sodabrew
Copy link
Collaborator

+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
Copy link
Collaborator

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'

@elcuervo
Copy link
Owner Author

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.

@sodabrew
Copy link
Collaborator

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.

@elcuervo
Copy link
Owner Author

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.

@sodabrew
Copy link
Collaborator

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.

@elcuervo
Copy link
Owner Author

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 😃

@sodabrew
Copy link
Collaborator

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.

@elcuervo
Copy link
Owner Author

😂 Awesome. I love being in the same page!.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants