Class: Eg::Music::MusicPlayer
- Inherits:
-
Object
- Object
- Eg::Music::MusicPlayer
- Defined in:
- lib/eg/music/music_player.rb
Constant Summary collapse
- @@playing =
nil- @@paused =
0
Class Method Summary collapse
- .minutes_remaining ⇒ Object
- .pause ⇒ Object
-
.play(music) ⇒ Object
Controls.
- .play_complete ⇒ Object
-
.play_started ⇒ Object
Events.
- .playing ⇒ Object
-
.seconds_remaining ⇒ Object
Status.
- .stop ⇒ Object
Class Method Details
.minutes_remaining ⇒ Object
57 58 59 |
# File 'lib/eg/music/music_player.rb', line 57 def MusicPlayer.minutes_remaining (MusicPlayer.seconds_remaining / 0.6).ceil / 100.0 end |
.pause ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/eg/music/music_player.rb', line 31 def MusicPlayer.pause Music.status = 'pause' if (not .nil?) and @@paused.zero? @@paused = (Simulator.next_play_complete - Simulator.time) Simulator.next_play_complete = 0 end end |
.play(music) ⇒ Object
Controls
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/eg/music/music_player.rb', line 19 def MusicPlayer.play music if @@paused.zero? Music.status = 'loading' seconds = (music == ) ? 0.3 : 2.5 Simulator.next_play_started = Simulator.schedule seconds else Music.status = 'playing' Simulator.next_play_complete = Simulator.schedule @@paused @@paused = 0 end end |
.play_complete ⇒ Object
69 70 71 72 |
# File 'lib/eg/music/music_player.rb', line 69 def MusicPlayer.play_complete Music.status = 'ready' = nil end |
.play_started ⇒ Object
Events
63 64 65 66 67 |
# File 'lib/eg/music/music_player.rb', line 63 def MusicPlayer.play_started Music.status = 'playing' = MusicLibrary.looking Simulator.next_play_complete = Simulator.schedule .seconds end |
.playing ⇒ Object
15 |
# File 'lib/eg/music/music_player.rb', line 15 def MusicPlayer.; ; end |
.seconds_remaining ⇒ Object
Status
47 48 49 50 51 52 53 54 55 |
# File 'lib/eg/music/music_player.rb', line 47 def MusicPlayer.seconds_remaining if not @@paused.zero? return @@paused elsif not .nil? return (Simulator.next_play_complete - Simulator.time) else return 0 end end |
.stop ⇒ Object
39 40 41 42 43 |
# File 'lib/eg/music/music_player.rb', line 39 def MusicPlayer.stop Simulator.next_play_started = 0 Simulator.next_play_complete = 0 play_complete end |