Class: AirPlayer::Media
- Inherits:
-
Object
- Object
- AirPlayer::Media
- Defined in:
- lib/airplayer/media.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
- #file? ⇒ Boolean
-
#initialize(target) ⇒ Media
constructor
A new instance of Media.
- #open ⇒ Object
- #url? ⇒ Boolean
Constructor Details
#initialize(target) ⇒ Media
Returns a new instance of Media.
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/airplayer/media.rb', line 25 def initialize(target) path = File.(target) @title = File.basename(path) if File.exist? path @video_server = AirPlayer::Server.new(path) @path = @video_server.uri @type = :file else @path = URI.encode(target) @type = :url end end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
23 24 25 |
# File 'lib/airplayer/media.rb', line 23 def path @path end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
23 24 25 |
# File 'lib/airplayer/media.rb', line 23 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
23 24 25 |
# File 'lib/airplayer/media.rb', line 23 def type @type end |
Class Method Details
.playable?(path) ⇒ Boolean
39 40 41 42 43 44 |
# File 'lib/airplayer/media.rb', line 39 def self.playable?(path) MIME::Types.type_for(path).each do |mimetype| return SUPPORTED_MIME_TYPES.include? mimetype end false end |
Instance Method Details
#close ⇒ Object
51 52 53 |
# File 'lib/airplayer/media.rb', line 51 def close @video_server.stop if file? end |
#file? ⇒ Boolean
55 56 57 |
# File 'lib/airplayer/media.rb', line 55 def file? @type == :file end |
#open ⇒ Object
46 47 48 49 |
# File 'lib/airplayer/media.rb', line 46 def open Thread.start { @video_server.start } if file? @path end |
#url? ⇒ Boolean
59 60 61 |
# File 'lib/airplayer/media.rb', line 59 def url? @type == :url end |