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.
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/cultome_player/player/interface/basic.rb', line 65 def next(cmd) if playlists[:queue].empty? unless cmd.params(:literal).any?{|p| p.value == 'no_history'} playlists[:history] << current_song end playlists[:queue] << playlists[:current].next end # aqui enviamos al reproductor externo a tocar play_queue 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.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/cultome_player/player/interface/basic.rb', line 42 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 |
# 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 else 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") end |
#prev(cmd) ⇒ Object
For more information on this command refer to user manual or inline help in interactive mode.
80 81 82 83 84 |
# File 'lib/cultome_player/player/interface/basic.rb', line 80 def prev(cmd) playlists[:queue] << playlists[:history].pop playlists[:current].rewind_by 1 execute("next no_history") end |
#quit(cmd) ⇒ Object
For more information on this command refer to user manual or inline help in interactive mode.
87 88 89 90 91 92 |
# File 'lib/cultome_player/player/interface/basic.rb', line 87 def quit(cmd) quit_in_player terminate_session return success("See you next time!") unless in_session? return failure("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.
59 60 61 62 |
# File 'lib/cultome_player/player/interface/basic.rb', line 59 def stop(cmd) stop_in_player success(message: "Stoped it!", paused: paused?, stopped: stopped?, playing: ) end |