playa 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +25 -14
- data/bin/playa +2 -0
- data/lib/playa/controller.rb +66 -0
- data/lib/playa/player.rb +63 -0
- data/lib/playa/track.rb +57 -0
- data/lib/playa/track_collection.rb +30 -0
- data/lib/playa/view.rb +23 -0
- data/lib/playa.rb +26 -0
- data/playa.gemspec +5 -1
- data/test/lib/playa/controller_test.rb +8 -0
- data/test/lib/playa/player_test.rb +7 -0
- data/test/lib/playa/track_collection_test.rb +34 -0
- data/test/lib/playa/track_test.rb +99 -0
- data/test/lib/playa/view_test.rb +8 -0
- data/test/lib/playa_test.rb +4 -0
- data/test/support/parkwalk.mp3 +0 -0
- data/test/test_helper.rb +0 -1
- metadata +63 -5
- data/lib/playa/.gitkeep +0 -0
- data/test/lib/.gitkeep +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69aac3236f6788c98ee9e99263f01b8c90828d2d
|
4
|
+
data.tar.gz: 1f425e19717680274ba1b8cc5abe9646e4a1aa67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd70ca6748135c6f147fe80dc9198f566d55eafcb7172cf83ba2103690a3ee61e058fe0ed3aff6da2e78aedf0ff983e71aec7105d8ae2d68ded3bd641fc5cc94
|
7
|
+
data.tar.gz: 9978f317618415a6427e6bf1bcf97a2e4dab0469093006ce7279c5cf2b86e31a0e2456e74ac8d919afaa466d571198f9092ca2aaf034aaec237ae5f6de31d182
|
data/README.md
CHANGED
@@ -1,29 +1,40 @@
|
|
1
1
|
# Playa
|
2
2
|
|
3
|
-
|
3
|
+
Plays mp3s from a directory. An example app using Vedeu.
|
4
4
|
|
5
|
-
## Installation
|
6
5
|
|
7
|
-
|
6
|
+
## Requirements
|
8
7
|
|
9
|
-
|
8
|
+
- Portaudio >= 19
|
9
|
+
- Mpg123 >= 1.14
|
10
10
|
|
11
|
-
And then execute:
|
12
11
|
|
13
|
-
|
12
|
+
### OSX Installation
|
14
13
|
|
15
|
-
|
14
|
+
brew install portaudio
|
15
|
+
brew install mpg123
|
16
|
+
gem install playa
|
17
|
+
|
18
|
+
### Debian / Ubuntu Install
|
19
|
+
|
20
|
+
apt-get install libjack0 libjack-dev
|
21
|
+
apt-get install libportaudiocpp0 portaudio19-dev libmpg123-dev
|
22
|
+
gem install playa
|
16
23
|
|
17
|
-
$ gem install playa
|
18
24
|
|
19
25
|
## Usage
|
20
26
|
|
21
|
-
|
27
|
+
playa
|
28
|
+
|
22
29
|
|
23
30
|
## Contributing
|
24
31
|
|
25
|
-
1. Fork it ( https://github.com/
|
26
|
-
2.
|
27
|
-
3.
|
28
|
-
4.
|
29
|
-
5. Create
|
32
|
+
1. Fork it ( https://github.com/gavinlaking/playa/fork )
|
33
|
+
2. Clone it
|
34
|
+
3. `bundle`
|
35
|
+
4. `rake` or `bundle exec guard`
|
36
|
+
5. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
6. Write some tests, write some code, have some fun
|
38
|
+
7. Commit your changes (`git commit -am 'Add some feature'`)
|
39
|
+
8. Push to the branch (`git push origin my-new-feature`)
|
40
|
+
9. Create a new Pull Request
|
data/bin/playa
CHANGED
@@ -0,0 +1,66 @@
|
|
1
|
+
module Playa
|
2
|
+
class Controller
|
3
|
+
include Vedeu
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
event :update do
|
7
|
+
@view = View.render(menu.items)
|
8
|
+
end
|
9
|
+
|
10
|
+
event :select do |track|
|
11
|
+
player.stop
|
12
|
+
|
13
|
+
@_player = Player.play(track)
|
14
|
+
end
|
15
|
+
|
16
|
+
event :complete do
|
17
|
+
trigger(:menu_next)
|
18
|
+
trigger(:select, menu.current_item)
|
19
|
+
end
|
20
|
+
|
21
|
+
event :key do |key|
|
22
|
+
case key
|
23
|
+
when :left
|
24
|
+
player.rewind
|
25
|
+
|
26
|
+
when :right
|
27
|
+
player.forward
|
28
|
+
|
29
|
+
when :space
|
30
|
+
player.toggle
|
31
|
+
|
32
|
+
when :enter
|
33
|
+
trigger(:menu_select)
|
34
|
+
trigger(:select, menu.current_item)
|
35
|
+
|
36
|
+
when :up
|
37
|
+
trigger(:menu_prev)
|
38
|
+
|
39
|
+
when :down
|
40
|
+
trigger(:menu_next)
|
41
|
+
|
42
|
+
when 'q'
|
43
|
+
trigger(:_exit_)
|
44
|
+
|
45
|
+
end
|
46
|
+
trigger(:update)
|
47
|
+
end
|
48
|
+
|
49
|
+
@view = View.render(menu.items)
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def menu
|
55
|
+
@_menu ||= Vedeu::Menu.new(tracks)
|
56
|
+
end
|
57
|
+
|
58
|
+
def tracks
|
59
|
+
@_tracks ||= TrackCollection.new.tracks
|
60
|
+
end
|
61
|
+
|
62
|
+
def player
|
63
|
+
@_player ||= Player.new
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/lib/playa/player.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'audite'
|
2
|
+
|
3
|
+
module Playa
|
4
|
+
class Player
|
5
|
+
attr_reader :track
|
6
|
+
|
7
|
+
def self.play(track)
|
8
|
+
new(track).start
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(track = nil)
|
12
|
+
@track = track
|
13
|
+
end
|
14
|
+
|
15
|
+
def start
|
16
|
+
open
|
17
|
+
|
18
|
+
play
|
19
|
+
end
|
20
|
+
|
21
|
+
def play
|
22
|
+
player.start_stream
|
23
|
+
end
|
24
|
+
|
25
|
+
def stop
|
26
|
+
player.stop_stream
|
27
|
+
end
|
28
|
+
|
29
|
+
def rewind
|
30
|
+
player.rewind(5)
|
31
|
+
end
|
32
|
+
|
33
|
+
def forward
|
34
|
+
player.forward(5)
|
35
|
+
end
|
36
|
+
|
37
|
+
def toggle
|
38
|
+
player.toggle
|
39
|
+
end
|
40
|
+
|
41
|
+
def playing?
|
42
|
+
player.active || false
|
43
|
+
end
|
44
|
+
|
45
|
+
def counter
|
46
|
+
player.position
|
47
|
+
end
|
48
|
+
|
49
|
+
def level
|
50
|
+
player.level
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def open
|
56
|
+
player.load(track.filename)
|
57
|
+
end
|
58
|
+
|
59
|
+
def player
|
60
|
+
@_player ||= Audite.new
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/playa/track.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'mp3info'
|
2
|
+
|
3
|
+
module Playa
|
4
|
+
class Track
|
5
|
+
def initialize(file)
|
6
|
+
@file = file
|
7
|
+
end
|
8
|
+
|
9
|
+
def attributes
|
10
|
+
{
|
11
|
+
filename: filename,
|
12
|
+
title: title,
|
13
|
+
artist: artist,
|
14
|
+
album: album,
|
15
|
+
track_number: track_number,
|
16
|
+
duration: duration,
|
17
|
+
bitrate: bitrate,
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def filename
|
22
|
+
id_tags.filename
|
23
|
+
end
|
24
|
+
|
25
|
+
def title
|
26
|
+
id_tags.tag.title || filename
|
27
|
+
end
|
28
|
+
|
29
|
+
def artist
|
30
|
+
id_tags.tag.artist || ''
|
31
|
+
end
|
32
|
+
|
33
|
+
def album
|
34
|
+
id_tags.tag.album || ''
|
35
|
+
end
|
36
|
+
|
37
|
+
def track_number
|
38
|
+
id_tags.tag.tracknum || 0
|
39
|
+
end
|
40
|
+
|
41
|
+
def duration
|
42
|
+
id_tags.length || 0
|
43
|
+
end
|
44
|
+
|
45
|
+
def bitrate
|
46
|
+
id_tags.bitrate || 0
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
attr_reader :file
|
52
|
+
|
53
|
+
def id_tags
|
54
|
+
@_id_tags ||= Mp3Info.open(file)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'playa/track'
|
2
|
+
|
3
|
+
module Playa
|
4
|
+
class TrackCollection
|
5
|
+
def initialize; end
|
6
|
+
|
7
|
+
def tracks
|
8
|
+
@_tracks ||= files.inject([]) do |acc, file|
|
9
|
+
acc << Track.new(file)
|
10
|
+
acc
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def files
|
15
|
+
@_files ||= Dir.glob(recursive).select do |file|
|
16
|
+
File.file?(file)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def recursive
|
23
|
+
directory + '/**/*'
|
24
|
+
end
|
25
|
+
|
26
|
+
def directory
|
27
|
+
'/Users/gavinlaking/Music/playa'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/playa/view.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Playa
|
2
|
+
class View
|
3
|
+
def self.render(menu)
|
4
|
+
new(menu).render
|
5
|
+
end
|
6
|
+
|
7
|
+
def initialize(menu)
|
8
|
+
@menu = menu
|
9
|
+
end
|
10
|
+
|
11
|
+
def render
|
12
|
+
Vedeu::Parser.parse(['playlist', playlist])
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
attr_reader :menu
|
18
|
+
|
19
|
+
def playlist
|
20
|
+
menu.map { |sel, cur, item| [sel, cur, item.title] }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/playa.rb
CHANGED
@@ -1,2 +1,28 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'vedeu'
|
3
|
+
|
4
|
+
require 'playa/track'
|
5
|
+
require 'playa/track_collection'
|
6
|
+
require 'playa/player'
|
7
|
+
require 'playa/view'
|
8
|
+
require 'playa/controller'
|
9
|
+
|
1
10
|
module Playa
|
11
|
+
class Application
|
12
|
+
include Vedeu
|
13
|
+
|
14
|
+
interface 'playlist' do
|
15
|
+
colour foreground: '#afd700', background: '#000000'
|
16
|
+
cursor false
|
17
|
+
width 60
|
18
|
+
height 10
|
19
|
+
centred true
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.start(args = [])
|
23
|
+
Controller.new
|
24
|
+
|
25
|
+
Vedeu::Launcher.new(args).execute!
|
26
|
+
end
|
27
|
+
end
|
2
28
|
end
|
data/playa.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'playa'
|
7
|
-
spec.version = '0.0.
|
7
|
+
spec.version = '0.0.2'
|
8
8
|
spec.authors = ['Gavin Laking']
|
9
9
|
spec.email = ['gavinlaking@gmail.com']
|
10
10
|
spec.summary = %q{Plays mp3s from a directory.}
|
@@ -25,4 +25,8 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency 'pry', '0.10.0'
|
26
26
|
spec.add_development_dependency 'rake', '10.3.2'
|
27
27
|
spec.add_development_dependency 'simplecov', '0.9.0'
|
28
|
+
|
29
|
+
spec.add_development_dependency 'audite'
|
30
|
+
spec.add_development_dependency 'ruby-mp3info'
|
31
|
+
spec.add_development_dependency 'vedeu'
|
28
32
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'playa/track_collection'
|
3
|
+
|
4
|
+
module Playa
|
5
|
+
describe TrackCollection do
|
6
|
+
describe '#tracks' do
|
7
|
+
it 'returns a collection of Track objects' do
|
8
|
+
files = [
|
9
|
+
"/some/path/dance.mp3"
|
10
|
+
]
|
11
|
+
collection = TrackCollection.new
|
12
|
+
collection.tracks.must_be_instance_of(Array)
|
13
|
+
collection.tracks.first.must_be_instance_of(Track)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#files' do
|
18
|
+
it 'returns a list of files for the specified directory' do
|
19
|
+
files = [
|
20
|
+
"/some/path/dance.mp3",
|
21
|
+
"/some/path/electro.mp3",
|
22
|
+
"/some/path/dubstep.mp3"
|
23
|
+
]
|
24
|
+
collection = TrackCollection.new
|
25
|
+
|
26
|
+
Dir.stub(:glob, files) do
|
27
|
+
File.stub(:file?, true) do
|
28
|
+
collection.files.must_equal(files)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
module Playa
|
5
|
+
describe Track do
|
6
|
+
let(:file) { '/some/path/electro.mp3' }
|
7
|
+
let(:tag) {
|
8
|
+
OpenStruct.new({
|
9
|
+
title: 'eee-lectro',
|
10
|
+
artist: 'Gavin Laking + Various',
|
11
|
+
album: 'That night at Sankeys',
|
12
|
+
tracknum: 3,
|
13
|
+
})
|
14
|
+
}
|
15
|
+
let(:mp3info) {
|
16
|
+
OpenStruct.new({
|
17
|
+
filename: '/some/path/electro.mp3',
|
18
|
+
tag: tag,
|
19
|
+
length: 3623.0270625,
|
20
|
+
bitrate: 320
|
21
|
+
})
|
22
|
+
}
|
23
|
+
let(:track) { Track.new(file) }
|
24
|
+
|
25
|
+
describe '#attributes' do
|
26
|
+
it 'returns a collection of attributes' do
|
27
|
+
Mp3Info.stub(:open, mp3info) do
|
28
|
+
track.attributes.must_equal(
|
29
|
+
{
|
30
|
+
filename: '/some/path/electro.mp3',
|
31
|
+
title: 'eee-lectro',
|
32
|
+
artist: 'Gavin Laking + Various',
|
33
|
+
album: 'That night at Sankeys',
|
34
|
+
track_number: 3,
|
35
|
+
duration: 3623.0270625,
|
36
|
+
bitrate: 320
|
37
|
+
}
|
38
|
+
)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#filename' do
|
44
|
+
it 'returns the filename' do
|
45
|
+
Mp3Info.stub(:open, mp3info) do
|
46
|
+
track.filename.must_equal('/some/path/electro.mp3')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#title' do
|
52
|
+
it 'returns the title' do
|
53
|
+
Mp3Info.stub(:open, mp3info) do
|
54
|
+
track.title.must_equal('eee-lectro')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#artist' do
|
60
|
+
it 'returns the artist' do
|
61
|
+
Mp3Info.stub(:open, mp3info) do
|
62
|
+
track.artist.must_equal('Gavin Laking + Various')
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe '#album' do
|
68
|
+
it 'returns the album' do
|
69
|
+
Mp3Info.stub(:open, mp3info) do
|
70
|
+
track.album.must_equal('That night at Sankeys')
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#track_number' do
|
76
|
+
it 'returns the track_number' do
|
77
|
+
Mp3Info.stub(:open, mp3info) do
|
78
|
+
track.track_number.must_equal(3)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe '#duration' do
|
84
|
+
it 'returns the duration' do
|
85
|
+
Mp3Info.stub(:open, mp3info) do
|
86
|
+
track.duration.must_equal(3623.0270625)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe '#bitrate' do
|
92
|
+
it 'returns the bitrate' do
|
93
|
+
Mp3Info.stub(:open, mp3info) do
|
94
|
+
track.bitrate.must_equal(320)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
Binary file
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: playa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Laking
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -122,6 +122,48 @@ dependencies:
|
|
122
122
|
- - '='
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 0.9.0
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: audite
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: ruby-mp3info
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: vedeu
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
125
167
|
description: An example app using Vedeu.
|
126
168
|
email:
|
127
169
|
- gavinlaking@gmail.com
|
@@ -140,9 +182,19 @@ files:
|
|
140
182
|
- Rakefile
|
141
183
|
- bin/playa
|
142
184
|
- lib/playa.rb
|
143
|
-
- lib/playa
|
185
|
+
- lib/playa/controller.rb
|
186
|
+
- lib/playa/player.rb
|
187
|
+
- lib/playa/track.rb
|
188
|
+
- lib/playa/track_collection.rb
|
189
|
+
- lib/playa/view.rb
|
144
190
|
- playa.gemspec
|
145
|
-
- test/lib
|
191
|
+
- test/lib/playa/controller_test.rb
|
192
|
+
- test/lib/playa/player_test.rb
|
193
|
+
- test/lib/playa/track_collection_test.rb
|
194
|
+
- test/lib/playa/track_test.rb
|
195
|
+
- test/lib/playa/view_test.rb
|
196
|
+
- test/lib/playa_test.rb
|
197
|
+
- test/support/parkwalk.mp3
|
146
198
|
- test/test_helper.rb
|
147
199
|
homepage: https://github.com/gavinlaking/playa
|
148
200
|
licenses:
|
@@ -169,5 +221,11 @@ signing_key:
|
|
169
221
|
specification_version: 4
|
170
222
|
summary: Plays mp3s from a directory.
|
171
223
|
test_files:
|
172
|
-
- test/lib
|
224
|
+
- test/lib/playa/controller_test.rb
|
225
|
+
- test/lib/playa/player_test.rb
|
226
|
+
- test/lib/playa/track_collection_test.rb
|
227
|
+
- test/lib/playa/track_test.rb
|
228
|
+
- test/lib/playa/view_test.rb
|
229
|
+
- test/lib/playa_test.rb
|
230
|
+
- test/support/parkwalk.mp3
|
173
231
|
- test/test_helper.rb
|
data/lib/playa/.gitkeep
DELETED
File without changes
|
data/test/lib/.gitkeep
DELETED
File without changes
|