airstream 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/airstream/device.rb +8 -0
- data/lib/airstream/player.rb +88 -0
- data/lib/airstream/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 613ee1b8dd6b1e90e3f648466107b08f5595d124
|
4
|
+
data.tar.gz: dbeff0d3fc6fe11057b6bf7ab7099dc6ae52e98f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d79d6b08991c69fadcbabb79c071c753c280b97781e7b1a0c1140ad09e6f0e9ea2c079cd9fe729baccaa6c568ea39fbc1e220492ca5a1e8184894781c7a2cffc
|
7
|
+
data.tar.gz: 3cc61eb71ab959d32159bec16bf17e9c16181489c797e549533cb06f8640712281a8f5826ddafaf3f6f466a699f6cad5f9012b07f7c317351b484bbc321f58c2
|
data/lib/airstream/device.rb
CHANGED
@@ -0,0 +1,88 @@
|
|
1
|
+
module Airstream
|
2
|
+
class Player
|
3
|
+
|
4
|
+
SEEK_SECONDS = 30
|
5
|
+
|
6
|
+
def initialize(device, files)
|
7
|
+
@device, @files = device, files
|
8
|
+
unless @files.empty?
|
9
|
+
play
|
10
|
+
else
|
11
|
+
@finished = true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def play(index=0)
|
16
|
+
unless @files.fetch(index, false)
|
17
|
+
err_msg = "no file found at index #{index}"
|
18
|
+
raise IndexError, err_msg
|
19
|
+
end
|
20
|
+
@file_index = index
|
21
|
+
self.current_file = @files[@file_index]
|
22
|
+
end
|
23
|
+
|
24
|
+
def current_file=(file)
|
25
|
+
# OPTIMIZE check if file exists (local, remote)
|
26
|
+
@device.file = file
|
27
|
+
end
|
28
|
+
private :current_file=
|
29
|
+
|
30
|
+
# TODO register commands instead of switch known
|
31
|
+
def update(io)
|
32
|
+
if io.quit?
|
33
|
+
Airstream::Io.show_input ; @finished = true
|
34
|
+
elsif io.skip? || duration <= elapsed_time
|
35
|
+
self.next
|
36
|
+
elsif io.prev?
|
37
|
+
self.prev
|
38
|
+
elsif io.fwd?
|
39
|
+
self.seek(elapsed_time + SEEK_SECONDS)
|
40
|
+
elsif io.back?
|
41
|
+
self.seek(elapsed_time - SEEK_SECONDS)
|
42
|
+
elsif io.pause?
|
43
|
+
@pause ||= false
|
44
|
+
(@pause = !@pause) ? @device.pause : @device.resume
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def seek(seconds)
|
49
|
+
if seconds.between? 0, duration
|
50
|
+
@device.scrub(seconds)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def next
|
55
|
+
@file_index += 1
|
56
|
+
if @file_index < @files.size
|
57
|
+
self.current_file = @files[@file_index]
|
58
|
+
else
|
59
|
+
@finished = true
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def prev
|
64
|
+
if @file_index == 0
|
65
|
+
self.seek(0)
|
66
|
+
elsif @files.size > @file_index
|
67
|
+
@file_index -= 1
|
68
|
+
self.current_file = @files[@file_index]
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def finished?
|
73
|
+
@finished || false
|
74
|
+
end
|
75
|
+
|
76
|
+
def loading?
|
77
|
+
elapsed_time == 0
|
78
|
+
end
|
79
|
+
|
80
|
+
def elapsed_time
|
81
|
+
@device.position
|
82
|
+
end
|
83
|
+
|
84
|
+
def duration
|
85
|
+
@device.duration
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
data/lib/airstream/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: airstream
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christoph Lipautz
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- lib/airstream/io.rb
|
99
99
|
- lib/airstream/network.rb
|
100
100
|
- lib/airstream/node.rb
|
101
|
+
- lib/airstream/player.rb
|
101
102
|
- lib/airstream/version.rb
|
102
103
|
- lib/airstream/video.rb
|
103
104
|
homepage: https://github.com/unused/airstream
|