airplayer 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- airplayer (0.0.3)
4
+ airplayer (0.0.4)
5
5
  airplay
6
+ mime-types
6
7
  rack
7
8
  ruby-progressbar
8
9
  thor
@@ -23,6 +24,7 @@ GEM
23
24
  guard (>= 1.1)
24
25
  rspec (~> 2.11)
25
26
  listen (0.5.3)
27
+ mime-types (1.19)
26
28
  net-http-digest_auth (1.2.1)
27
29
  net-http-persistent (2.7)
28
30
  rack (1.4.1)
@@ -98,6 +98,19 @@ $ airplayer play '~/Movies/Trailers/007 SKYFALL.mp4' --repeat
98
98
  ```
99
99
 
100
100
 
101
+ Supported MIME types
102
+ --------------------------------------------------------------------------------
103
+
104
+ [AirPlay Overview - Configuring Your Server](http://developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/AirPlayGuide/PreparingYourMediaforAirPlay/PreparingYourMediaforAirPlay.html)
105
+
106
+ File extension | MIME type | Ruby `mime-types`
107
+ -------------- | --------------- | -----------------------------
108
+ .ts | video/MP2T | video/MP2T
109
+ .mov | video/quicktime | video/quicktime
110
+ .m4v | video/mpeg4 | video/vnd.objectvideo
111
+ .mp4 | video/mpeg4 | application/mp4, video/mp4
112
+
113
+
101
114
  LICENSE
102
115
  --------------------------------------------------------------------------------
103
116
 
@@ -19,6 +19,7 @@ Gem::Specification.new do |gem|
19
19
  gem.add_runtime_dependency 'ruby-progressbar'
20
20
  gem.add_runtime_dependency 'airplay'
21
21
  gem.add_runtime_dependency 'rack'
22
+ gem.add_runtime_dependency 'mime-types'
22
23
 
23
24
  gem.add_development_dependency 'rake'
24
25
  gem.add_development_dependency 'rspec'
@@ -1,6 +1,24 @@
1
1
  require 'uri'
2
+ require 'mime/types'
2
3
 
3
4
  module AirPlayer
5
+ # http://developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/AirPlayGuide/PreparingYourMediaforAirPlay/PreparingYourMediaforAirPlay.html
6
+ #
7
+ # File Extension | MIME type | Ruby `mime-types`
8
+ # -------------- | --------------- | -----------------------------
9
+ # .ts | video/MP2T | video/MP2T
10
+ # .mov | video/quicktime | video/quicktime
11
+ # .m4v | video/mpeg4 | video/vnd.objectvideo
12
+ # .mp4 | video/mpeg4 | application/mp4, video/mp4
13
+ SUPPORTED_MIME_TYPES = %w[
14
+ application/mp4
15
+ video/mp4
16
+ video/vnd.objectvideo
17
+ video/MP2T
18
+ video/quicktime
19
+ video/mpeg4
20
+ ]
21
+
4
22
  class Media
5
23
  attr_reader :title, :path, :type
6
24
 
@@ -18,6 +36,13 @@ module AirPlayer
18
36
  end
19
37
  end
20
38
 
39
+ def self.playable?(path)
40
+ MIME::Types.type_for(path).each do |mimetype|
41
+ return SUPPORTED_MIME_TYPES.include? mimetype
42
+ end
43
+ false
44
+ end
45
+
21
46
  def open
22
47
  Thread.start { @video_server.start } if file?
23
48
  @path
@@ -17,7 +17,7 @@ module AirPlayer
17
17
  def media_in(path)
18
18
  Dir.entries(path).map do |node|
19
19
  media_path = File.expand_path(node, path)
20
- Media.new(media_path) if File.file? media_path
20
+ Media.new(media_path) if Media.playable? media_path
21
21
  end.compact
22
22
  end
23
23
  end
@@ -1,3 +1,3 @@
1
1
  module AirPlayer
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
@@ -18,6 +18,16 @@ describe :AirPlayer do
18
18
  end
19
19
 
20
20
  context :Media do
21
+ it 'check supported mime types' do
22
+ expect(AirPlayer::Media.playable?('007 SKYFALL.mp4')).to be_true
23
+ expect(AirPlayer::Media.playable?('007 SKYFALL.ts')).to be_true
24
+ expect(AirPlayer::Media.playable?('007 SKYFALL.m4v')).to be_true
25
+ expect(AirPlayer::Media.playable?('007 SKYFALL.mov')).to be_true
26
+ expect(AirPlayer::Media.playable?('007 SKYFALL.ts')).to be_true
27
+ expect(AirPlayer::Media.playable?('007 SKYFALL.flv')).to be_false
28
+ expect(AirPlayer::Media.playable?('007 SKYFALL.wmv')).to be_false
29
+ expect(AirPlayer::Media.playable?('.DS_Store')).to be_false
30
+ end
21
31
  it 'give to local file' do
22
32
  media = AirPlayer::Media.new('./Gemfile')
23
33
  expect(media.file?).to be_true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: airplayer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-06 00:00:00.000000000 Z
12
+ date: 2012-10-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -75,6 +75,22 @@ dependencies:
75
75
  - - ! '>='
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: mime-types
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
78
94
  - !ruby/object:Gem::Dependency
79
95
  name: rake
80
96
  requirement: !ruby/object:Gem::Requirement
@@ -167,7 +183,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
167
183
  version: '0'
168
184
  segments:
169
185
  - 0
170
- hash: 1247565518444440084
186
+ hash: 1446557728728225776
171
187
  required_rubygems_version: !ruby/object:Gem::Requirement
172
188
  none: false
173
189
  requirements:
@@ -176,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
192
  version: '0'
177
193
  segments:
178
194
  - 0
179
- hash: 1247565518444440084
195
+ hash: 1446557728728225776
180
196
  requirements: []
181
197
  rubyforge_project:
182
198
  rubygems_version: 1.8.23