airplayer 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  language: ruby
2
- before_script:
3
- - sudo apt-get -qq update
4
- - sudo apt-get -qq install rdnssd libavahi-compat-libdnssd-dev
2
+ before_install:
3
+ - 'sudo apt-get -qq update'
4
+ - 'sudo apt-get -qq install rdnssd libavahi-compat-libdnssd-dev'
5
5
  script: bundle exec rake spec
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- airplayer (0.0.1)
4
+ airplayer (0.0.2)
5
5
  airplay
6
6
  rack
7
7
  ruby-progressbar
@@ -19,6 +19,7 @@ GEM
19
19
  net-http-digest_auth (1.2.1)
20
20
  net-http-persistent (2.7)
21
21
  rack (1.4.1)
22
+ rake (0.9.2.2)
22
23
  rspec (2.11.0)
23
24
  rspec-core (~> 2.11.0)
24
25
  rspec-expectations (~> 2.11.0)
@@ -35,4 +36,5 @@ PLATFORMS
35
36
 
36
37
  DEPENDENCIES
37
38
  airplayer!
39
+ rake
38
40
  rspec
@@ -1,11 +1,12 @@
1
1
  AirPlayer
2
2
  ================================================================================
3
3
 
4
- Command-line AirPlay video client for AppleTV
4
+ Command-line AirPlay video client for Apple TV
5
5
 
6
6
  [![Build Status](https://secure.travis-ci.org/Tomohiro/airplayer.png)](https://secure.travis-ci.org/Tomohiro/airplayer)
7
7
  [![Dependency Status](https://gemnasium.com/Tomohiro/airplayer.png)](https://gemnasium.com/Tomohiro/airplayer)
8
8
  [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/Tomohiro/airplayer)
9
+ [![endorse](http://api.coderwall.com/tomohiro/endorsecount.png)](http://coderwall.com/tomohiro)
9
10
 
10
11
 
11
12
  ---
@@ -18,24 +19,30 @@ Requirements
18
19
  - AppleTV 2G or later
19
20
 
20
21
 
21
- Installation
22
- --------------------------------------------------------------------------------
23
-
24
- ## Bundler
22
+ ### Ubuntu
25
23
 
26
24
  ```sh
27
- $ git clone git://github.com/Tomohiro/airplayer.git
28
- $ cd airplayer
29
- $ bundle install --path vendor/bundle
25
+ $ sudo apt-get install rdnssd libavahi-compat-libdnssd-dev
30
26
  ```
31
27
 
32
28
 
29
+ Installation
30
+ --------------------------------------------------------------------------------
31
+
33
32
  ### RubyGems
34
33
 
35
34
  ```sh
36
35
  $ gem install airplayer
37
36
  ```
38
37
 
38
+ ### Bundler
39
+
40
+ ```sh
41
+ $ git clone git://github.com/Tomohiro/airplayer.git
42
+ $ cd airplayer
43
+ $ bundle install --path vendor/bundle
44
+ ```
45
+
39
46
 
40
47
  Usage
41
48
  --------------------------------------------------------------------------------
@@ -57,6 +64,16 @@ AirPlay: http://10.0.1.13:7070 to Apple TV(10.0.1.18)
57
64
  ```
58
65
 
59
66
 
67
+ ### Repeat play
68
+
69
+ ```sh
70
+ $ airplayer play ./video.mp4 --repeat
71
+ AirPlay: http://10.0.1.13:7070 to Apple TV(10.0.1.18)
72
+ Time: 00:00:31 |===================== | 50% Streaming
73
+ ```
74
+
75
+
76
+
60
77
  LICENSE
61
78
  --------------------------------------------------------------------------------
62
79
 
@@ -6,8 +6,8 @@ Gem::Specification.new do |gem|
6
6
  gem.version = AirPlayer::VERSION
7
7
  gem.authors = ['Tomohiro, TAIRA']
8
8
  gem.email = ['tomohiro.t@gmail.com']
9
- gem.description = %q{Command-line AirPlay video client for AppleTV}
10
- gem.summary = %q{Command-line AirPlay video client for AppleTV}
9
+ gem.description = %q{Command-line AirPlay video client for Apple TV}
10
+ gem.summary = %q{Command-line AirPlay video client for Apple TV}
11
11
  gem.homepage = 'https://github.com/Tomohiro/airplayer'
12
12
 
13
13
  gem.files = `git ls-files`.split($\)
@@ -20,5 +20,6 @@ Gem::Specification.new do |gem|
20
20
  gem.add_runtime_dependency 'airplay'
21
21
  gem.add_runtime_dependency 'rack'
22
22
 
23
+ gem.add_development_dependency 'rake'
23
24
  gem.add_development_dependency 'rspec'
24
25
  end
@@ -2,6 +2,7 @@ require 'rubygems'
2
2
  require 'airplayer/version'
3
3
 
4
4
  module AirPlayer
5
+ autoload :Logger, 'airplayer/logger'
5
6
  autoload :App, 'airplayer/app'
6
7
  autoload :Player, 'airplayer/player'
7
8
  autoload :Server, 'airplayer/server'
@@ -2,9 +2,10 @@ require 'thor'
2
2
 
3
3
  module AirPlayer
4
4
  class App < Thor
5
- desc 'play [URI|FILE]', 'Play video(URI or local video file path)'
5
+ desc 'play <URI|FILE> [-r|--repeat]', 'Play video(URI or local video file path)'
6
+ method_option :repeat, :aliases => '-r', :desc => 'Repeat play'
6
7
  def play(uri)
7
- Player.new.play(uri)
8
+ Player.play(uri, options.repeat?)
8
9
  end
9
10
 
10
11
  map '--version' => :version
@@ -0,0 +1,18 @@
1
+ require 'rbconfig'
2
+
3
+ module AirPlayer
4
+ class Logger
5
+ def self.path
6
+ case RbConfig::CONFIG['target_os']
7
+ when /darwin|osx/i
8
+ File.expand_path('~/Library/Logs/airplayer-access.log')
9
+ when /linux|unix/i
10
+ '/tmp/airplayer-access.log'
11
+ when /mswin|windows|cygwin/i
12
+ 'NUL'
13
+ else
14
+ STDOUT
15
+ end
16
+ end
17
+ end
18
+ end
@@ -7,6 +7,12 @@ module AirPlayer
7
7
  class Player
8
8
  BufferingTimeoutError = Class.new(TimeoutError)
9
9
 
10
+ def self.play(*opts)
11
+ new.play(*opts)
12
+ rescue Airplay::Client::ServerNotFoundError
13
+ abort '[ERROR] Apple device not found'
14
+ end
15
+
10
16
  def initialize
11
17
  @airplay = Airplay::Client.new
12
18
  @player = nil
@@ -17,7 +23,7 @@ module AirPlayer
17
23
  @current_sec = 0
18
24
  end
19
25
 
20
- def play(target)
26
+ def play(target, repeat = false)
21
27
  path = File.expand_path(target)
22
28
  if local_file? path
23
29
  video_server = AirPlayer::Server.new(path)
@@ -29,16 +35,27 @@ module AirPlayer
29
35
 
30
36
  device = @airplay.browse.first
31
37
  puts "AirPlay: #{uri} to #{device.name}(#{device.ip})"
32
-
33
38
  @progressbar = ProgressBar.create(:format => ' %a |%b%i| %p%% %t', :title => :Waiting)
34
39
  @player = @airplay.send_video(uri)
35
- buffering
36
- while playing do
37
- @progressbar.progress = @current_sec
40
+
41
+ loop do
42
+ buffering
43
+ @progressbar.progress = @current_sec while playing
44
+ break unless repeat
45
+ reset
38
46
  end
47
+
39
48
  stop
40
49
  rescue BufferingTimeoutError
41
- abort 'Buffering timeout error.'
50
+ abort '[ERROR] Buffering timeout'
51
+ end
52
+
53
+ def reset
54
+ @player.scrub(0)
55
+ @player.resume
56
+
57
+ @progressbar.reset
58
+ @progressbar.resume
42
59
  end
43
60
 
44
61
  def stop
@@ -12,8 +12,8 @@ module AirPlayer
12
12
  end
13
13
 
14
14
  def start
15
- # silenced WEBrick access log
16
- $stderr = File.open('/dev/null', 'w')
15
+ # Output WEBrick access log to file
16
+ $stderr = File.open(Logger.path, File::WRONLY | File::APPEND | File::CREAT)
17
17
  @server.start
18
18
  $stderr = STDERR
19
19
  end
@@ -1,3 +1,3 @@
1
1
  module AirPlayer
2
- VERSION = "0.0.1"
2
+ VERSION = '0.0.2'
3
3
  end
@@ -2,9 +2,16 @@ require 'spec_helper'
2
2
 
3
3
  describe AirPlayer do
4
4
  let(:app) { AirPlayer::App.new }
5
+
5
6
  context 'App' do
6
7
  it 'class type is Thor' do
7
8
  expect(app).to be_kind_of Thor
8
9
  end
9
10
  end
11
+
12
+ context 'Logger' do
13
+ it 'file path is /tmp/airplayer-access.log on Linux' do
14
+ expect(AirPlayer::Logger.path).to eq '/tmp/airplayer-access.log'
15
+ end
16
+ end
10
17
  end
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.1
4
+ version: 0.0.2
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-09-21 00:00:00.000000000 Z
12
+ date: 2012-09-27 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: rake
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
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: rspec
80
96
  requirement: !ruby/object:Gem::Requirement
@@ -91,7 +107,7 @@ dependencies:
91
107
  - - ! '>='
92
108
  - !ruby/object:Gem::Version
93
109
  version: '0'
94
- description: Command-line AirPlay video client for AppleTV
110
+ description: Command-line AirPlay video client for Apple TV
95
111
  email:
96
112
  - tomohiro.t@gmail.com
97
113
  executables:
@@ -111,6 +127,7 @@ files:
111
127
  - bin/airplayer
112
128
  - lib/airplayer.rb
113
129
  - lib/airplayer/app.rb
130
+ - lib/airplayer/logger.rb
114
131
  - lib/airplayer/player.rb
115
132
  - lib/airplayer/progress_bar/base.rb
116
133
  - lib/airplayer/server.rb
@@ -131,7 +148,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
148
  version: '0'
132
149
  segments:
133
150
  - 0
134
- hash: -1081237066405276269
151
+ hash: 2589441194092994510
135
152
  required_rubygems_version: !ruby/object:Gem::Requirement
136
153
  none: false
137
154
  requirements:
@@ -140,13 +157,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
157
  version: '0'
141
158
  segments:
142
159
  - 0
143
- hash: -1081237066405276269
160
+ hash: 2589441194092994510
144
161
  requirements: []
145
162
  rubyforge_project:
146
163
  rubygems_version: 1.8.23
147
164
  signing_key:
148
165
  specification_version: 3
149
- summary: Command-line AirPlay video client for AppleTV
166
+ summary: Command-line AirPlay video client for Apple TV
150
167
  test_files:
151
168
  - spec/airplayer_spec.rb
152
169
  - spec/spec_helper.rb