Module: CultomePlayer::Player::Interface::Basic
- Included in:
- CultomePlayer::Player::Interface
- Defined in:
- lib/cultome_player/player/interface/basic.rb
Instance Method Summary collapse
-
#next(cmd) ⇒ Object
For more information on this command refer to user manual or inline help in interactive mode.
-
#pause(cmd) ⇒ Object
For more information on this command refer to user manual or inline help in interactive mode.
-
#play(cmd) ⇒ Object
For more information on this command refer to user manual or inline help in interactive mode.
-
#prev(cmd) ⇒ Object
For more information on this command refer to user manual or inline help in interactive mode.
-
#quit(cmd) ⇒ Object
For more information on this command refer to user manual or inline help in interactive mode.
-
#stop(cmd) ⇒ Object
For more information on this command refer to user manual or inline help in interactive mode.
Instance Method Details
#next(cmd) ⇒ Object
For more information on this command refer to user manual or inline help in interactive mode.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/cultome_player/player/interface/basic.rb', line 66 def next(cmd) playlists[:history] << current_song if cmd.history? if playlists[:queue].empty? playlists[:queue] << playlists[:current].next end # aqui enviamos al reproductor externo a tocar play_queue # cambiamos la fecha de ultima reproduccion current_song.update_attributes(last_played_at: Time.now) return success(message: "Now playing #{current_song}", now_playing: current_song) end |
#pause(cmd) ⇒ Object
For more information on this command refer to user manual or inline help in interactive mode.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/cultome_player/player/interface/basic.rb', line 43 def pause(cmd) if cmd.params.empty? is_pause = !paused? else is_pause = cmd.params(:boolean).first.value end if is_pause pause_in_player else resume_in_player end success(message: is_pause ? "Holding your horses" : "Letting it flow", paused: paused?, stopped: stopped?, playing: ) end |
#play(cmd) ⇒ Object
For more information on this command refer to user manual or inline help in interactive mode.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/cultome_player/player/interface/basic.rb', line 7 def play(cmd) if cmd.params.empty? # Estos los consideramos comportamientos inteligentes # porque checan el contexto y toman una descision, # por lo tanto la logica no aplica a el comando play normal # tocar mientras ya estamos tocando algo?? return failure("What you mean? Im already playing!") if # quitamos la pausa return execute "pause off" if paused? # iniciamos ultima la reproduccion desde el principio if stopped? && current_song curr_song = player_object :song return execute "play @song" end # tocamos toda la libreria songs = whole_library return failure("No music connected! You should try 'connect /home/yoo/music => main' first") if songs.empty? playlists[:current, :focus] <= songs playlists[:current, :focus].shuffle else # with parameters songs = select_songs_with cmd # checamos si el tipo de comando es para programar una # nueva playlist o solo para tocar una cancion if play_inline?(cmd) playlists[:queue] << songs else playlists[:current] <= songs end end return success(playlist: songs) + execute("next no_history").first end |
#prev(cmd) ⇒ Object
For more information on this command refer to user manual or inline help in interactive mode.
83 84 85 86 87 88 |
# File 'lib/cultome_player/player/interface/basic.rb', line 83 def prev(cmd) playlists[:queue] << playlists[:history].pop playlists[:current].rewind_by 1 r = execute("next no_history").first return r end |
#quit(cmd) ⇒ Object
For more information on this command refer to user manual or inline help in interactive mode.
91 92 93 94 95 96 |
# File 'lib/cultome_player/player/interface/basic.rb', line 91 def quit(cmd) quit_in_player terminate_session return success(c15("See you next time!")) unless in_session? return failure(c3("Oops! You should use Ctr-c or throw water to the CPU NOW!!!!")) end |
#stop(cmd) ⇒ Object
For more information on this command refer to user manual or inline help in interactive mode.
60 61 62 63 |
# File 'lib/cultome_player/player/interface/basic.rb', line 60 def stop(cmd) stop_in_player success(message: "Stoped it!", paused: paused?, stopped: stopped?, playing: ) end |