class MultimediaParadise::AudioPlayer

Constants

AUDIO_DIR
AVAILABLE_SONGS
#

AVAILABLE_SONGS

Obtain all available songs - and shuffle them a bit.

#
DEFAULT_DELAY_PLAYING_SONGS
#

DEFAULT_DELAY_PLAYING_SONGS

The following constant is used for determining the audio delay between two songs.

A value of 0.0 would mean no delay, aka “instant play”, logically.

#
DEFAULT_PLAYMODE
#

DEFAULT_PLAYMODE

#
FULL_LOCATION_FOR_LAST_SONG_PLAYED
#

FULL_LOCATION_FOR_LAST_SONG_PLAYED

#
LAST_SONG_PLAYED
#

LAST_SONG_PLAYED

#
MAIN_AUDIO_PLAYER_TO_USE
MAXIMUM_ALLOWED_FILE_SIZE
#

MAXIMUM_ALLOWED_FILE_SIZE

#
MY_SONGS
#

MY_SONGS

#
NAMESPACE
#

NAMESPACE

#
NAME_OF_AUDIO_PLAYER
#

NAME_OF_AUDIO_PLAYER

#
PLAYLIST_CONSTANTS
PLAY_MAX_N_SONGS
#

PLAY_MAX_N_SONGS

#
RENAME_KDE_KONSOLE_TAB
#

RENAME_KDE_KONSOLE_TAB

#
SHALL_WE_DEBUG
#

SHALL_WE_DEBUG

#
THE_LOG_FILE_IS_STORED_HERE
#

THE_LOG_FILE_IS_STORED_HERE

#
USE_FAVOURITE_PLAYLIST
#

USE_FAVOURITE_PLAYLIST

#
USE_OSS_FOR_AUDIO_PLAYER
#

USE_OSS_FOR_AUDIO_PLAYER

#

Public Class Methods

new( i = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 30
def initialize(
    i           = nil,
    run_already = true
  )
  register_sigint { :pretty }
  reset
  if i
    i = set_commandline_options_and_return_the_other_options(i)
    menu(i)
  end
  case run_already
  # ======================================================================= #
  # === :dont_run_yet
  # ======================================================================= #
  when :dont_run_yet,
       :do_not_run_yet
    run_already = false
  end
  run if run_already
end

Public Instance Methods

add( i = nil )
Alias for: add_song
add_all_songs() click to toggle source
#

add_all_songs

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 314
def add_all_songs
  add(all_songs?)
end
add_random_song() click to toggle source
#

add_random_song

This will add exactly one random song.

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 213
def add_random_song
  add_song(return_random_song)
end
add_song( i = nil ) click to toggle source
#

add_song (add tag)

This method will add the particular song to the playlist.

It will check whether it is an multimedia-file prior to adding it, though.

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 422
def add_song(
    i = nil
  )
  unless i.nil?
    [i].flatten.compact.each {|this_song|
      if is_a_multimedia_file?(this_song)
        @array_play_these_songs << this_song
      end
    }
    sanitize_songs
  end
end
add_songs( i = nil )
Alias for: add_song
add_this_song( i = nil )
Alias for: add_song
add_this_song_to_playlist( i = nil )
Alias for: add_song
add_to_playlist( i = nil )
Alias for: add_song
all_songs()
Alias for: return_all_songs
all_songs?()
Alias for: return_all_songs
audio_dir?() click to toggle source
#

audio_dir?

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 289
def audio_dir?
  AUDIO_DIR
end
audio_player?()
audio_player_to_use?() click to toggle source
#

audio_player_to_use?

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 600
def audio_player_to_use?
  @audio_player_to_use
end
check_against_menu(i)
Alias for: menu
check_whether_the_song_directory_is_empty() click to toggle source
#

check_whether_the_song_directory_is_empty

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 340
def check_whether_the_song_directory_is_empty
  if return_all_songs.empty?
    opnn; e 'No songs found in `'+sdir(audio_dir?)+'`.'
    opnn; e 'Perhaps you forgot to copy some songs first?'
    exit_program(:force_exit)
  end
end
clear_playlist()
Alias for: reset_playlist
consider_renaming_the_kde_konsole_tab(i) click to toggle source
#

consider_renaming_the_kde_konsole_tab

#
# File lib/multimedia_paradise/audio/audio_player/tab.rb, line 14
def consider_renaming_the_kde_konsole_tab(i)
  # ======================================================================= #
  # === Rename the KDE Konsole tab here
  # ======================================================================= #
  if Object.const_defined? :Roebe
    begin
      i = File.basename(i).
          gsub(/#{File.extname(i)}$/,'').
          tr('_',' ')
    # ===================================================================== #
    # Must rescue this, in case of errors such as:
    #   invalid byte sequence in UTF-8
    # ===================================================================== #
    rescue ArgumentError => error
      opnn; e 'An error happened (ArgumentError) which is now displayed:'
      pp error
    end
    Roebe.rename_konsole(i)
  end if RENAME_KDE_KONSOLE_TAB
end
consider_resetting_kde_konsole_tab( use_this_as_the_new_title = '.' ) click to toggle source
#

consider_resetting_kde_konsole_tab

This method can be used to re-set the KDE konsole tab name.

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 456
def consider_resetting_kde_konsole_tab(
    use_this_as_the_new_title = '.'
  )
  do_rename_konsole(
    use_this_as_the_new_title, RENAME_KDE_KONSOLE_TAB
  )
end
delay?() click to toggle source
#

delay?

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 608
def delay?
  @delay.to_s
end
determine_available_songs()
Alias for: return_all_songs
determine_which_audio_player_to_use( i = MAIN_AUDIO_PLAYER_TO_USE, overrule_if_environment_variable_was_set = true ) click to toggle source
#

determine_which_audio_player_to_use

This method will determine which audio play is to be used, for playing the audio files. Currently the two primary ones that I use are mplayer and mpv. Note that the environment variable MAIN_AUDIO_PLAYER can overrule this completely, if set.

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 59
def determine_which_audio_player_to_use(
    i                                        = MAIN_AUDIO_PLAYER_TO_USE,
    overrule_if_environment_variable_was_set = true
  )
  case overrule_if_environment_variable_was_set
  # ======================================================================= #
  # === :ignore_environment_variable
  # ======================================================================= #
  when :ignore_environment_variable
    overrule_if_environment_variable_was_set = false
  end
  case i
  # ======================================================================= #
  # === sox
  # ======================================================================= #
  when 'sox',
       :sox
    i = 'play' # The binary from sox is actually called "play", hence this line.
  end
  if overrule_if_environment_variable_was_set
    if ENV.has_key? 'MAIN_AUDIO_PLAYER'
      i = ENV['MAIN_AUDIO_PLAYER'].to_s.dup
    end
  end
  @audio_player_to_use = i.to_s # Which audio player to use.
end
do_play_in_a_loop() click to toggle source
#

do_play_in_a_loop

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 227
def do_play_in_a_loop
  @play_in_a_loop = true
end
do_rename_konsole( i = '.', *optional_arguments_that_are_irrelevant ) click to toggle source
#

do_rename_konsole

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 551
def do_rename_konsole(
    i = '.', *optional_arguments_that_are_irrelevant
  )
  if Object.const_defined? :Roebe
    Roebe.rename_konsole(i)
  end
end
exit_program( shall_we_exit = shall_we_exit?, be_verbose = true ) { || ... } click to toggle source
#

exit_program

This method can be used to exit this program.

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 353
def exit_program(
    shall_we_exit = shall_we_exit?,
    be_verbose    = true,
    &block
  )
   
  case shall_we_exit
  # ======================================================================= #
  # === :force_exit
  # ======================================================================= #
  when :force_exit
    shall_we_exit = true
  # ======================================================================= #
  # === :force_exit_but_be_quiet
  # ======================================================================= #
  when :force_exit_but_be_quiet
    shall_we_exit = true
    be_verbose = false
  end
  # ======================================================================= #
  # === Handle blocks next
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :be_quiet
    # ===================================================================== #
    when :be_quiet
      be_verbose = false
    end
  end
  if shall_we_exit
    @mrxvt.set_title('') if @mrxvt
    if be_verbose
      efancy 'Leaving ...'
      efancy 'Hopefully you had fun and found class'\
             'MultimediaParadise::AudioPlayer useful. Bye!'
    end
    consider_resetting_kde_konsole_tab
    exit
  else
    e "Won't exit as we are not allowed to exit."
  end
end
fetch_random_song()
Alias for: return_random_song
get_all_songs()
Alias for: return_all_songs
get_file_size( of_this_file = the_songs_played_will_be_stored_where? ) click to toggle source
#

get_file_size

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 154
def get_file_size(
    of_this_file = the_songs_played_will_be_stored_where?
  )
  size = 0
  size = File.size(of_this_file) if File.exist?(of_this_file)
  size
end
get_random_song()
Alias for: return_random_song
input?() click to toggle source
#

input?

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 402
def input?
  @array_play_these_songs
end
Also aliased as: play_these_songs, playlist?
main_colour?() click to toggle source
#

main_colour?

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 253
def main_colour?
  @main_colour
end
Also aliased as: mcol?
mcol?()
Alias for: main_colour?
menu(i) click to toggle source
#

menu (menu tag)

#
Also aliased as: check_against_menu
obtain_file_duration_from_this_file(i) click to toggle source
#

obtain_file_duration_from_this_file(i)

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 23
def obtain_file_duration_from_this_file(i)
  MultimediaParadise::FileDuration[i]
end
pause( n_seconds = delay? ) click to toggle source
#

pause (pause tag)

Pause for n_seconds (the first input to this method).

This method will NOT seet a new, random song - for this, you need to use another method.

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 491
def pause(
    n_seconds = delay?
  )
  n_seconds = n_seconds.to_f # Always keep it as a float here.
  cliner
  e "#{true_rev}We will pause for #{sfancy(n_seconds)} seconds."
  cliner_with_time_stamp
  e 'The next song will be: '+sfancy(
       playlist?[@n_songs_played]
     )
  cliner
  sleep(n_seconds)
end
perform_cleanup() click to toggle source
#

perform_cleanup

We get rid of @ivars which are not too useful.

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 333
def perform_cleanup
  remove_instance_variable :@available_genres
end
play_the_playlist() click to toggle source
#

play_the_playlist

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 640
def play_the_playlist
  if @play_in_a_loop # We wish to play in a never-ending loop.
    counter = 0
    loop {
      playlist?.each {|song|
        play_this_song(song)
        pause unless @n_songs_played == playlist?.size
        counter += 1
        break if counter > @play_max_n_songs
      }
      refresh_playlist
    }
  else
    playlist?.each {|song|
      play_this_song(song)
      pause unless @n_songs_played == playlist?.size
    } # Afterwards, we will have exited.
  end
end
play_these_songs()
Alias for: input?
play_this_song( i, be_verbose = true ) click to toggle source
#

play_this_song (play tag)

This is the actual method that will play the song.

We will also append the filename last played.

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 512
def play_this_song(
    i, be_verbose = true
  )
  if be_verbose 
    e; opnn; e 'The next song we will play via '+
                simp(audio_player_to_use?)+' is:'
    e "#{N}   #{sfancy(i)}#{N}#{N}"
  end
  # ======================================================================= #
  # Next, act on .mp3 files.
  # ======================================================================= #
  if File.extname(i) == '.mp3'
    begin
      @file_duration_in_seconds = obtain_file_duration_from_this_file(i)
      if be_verbose
        e 'The length of this song is: '+
          sfancy("#{@file_duration_in_seconds.to_i} seconds")+'.'
      end
    rescue Exception => error
      e error
    end
  end
  e "  #{sfile(i)}" if be_verbose
  consider_renaming_the_kde_konsole_tab(i)
  _ = audio_player?.dup
  _ << ' -ao oss' if @use_oss_for_audio_player
  _ << ' '+i.dup
  # ======================================================================= #
  # Register which song was played. We do this before we actually play
  # the song.
  # ======================================================================= #
  register_which_song_will_be_played_next(i)
  esystem _
  @n_songs_played += 1
end
playlist?()
Alias for: input?
populate_hash_songs_played() click to toggle source
#

populate_hash_songs_played

Fills up our hash with available data for the first time. Basically right now, only manipulates @hash_songs_played

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 134
def populate_hash_songs_played
  playlist?.each { |song|
    song = File.basename(song)
    @hash_songs_played[song] = 0
  }
end
refresh_playlist() click to toggle source
#

refresh_playlist

First clears the playlist, then adds all available songs.

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 323
def refresh_playlist
  clear_playlist
  add_all_songs
end
register_sigint() click to toggle source
#

register_sigint

Will act upon SIGINT recieved, and properly shut down.

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 444
def register_sigint
  Signal.trap('SIGINT') {
    consider_resetting_kde_konsole_tab
    exit_program(true)
  }
end
register_this_song(this_song) click to toggle source
#

register_this_song

This method should be invoked whenever you want to play a new song.

We will only keep the filename, not the full location.

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 300
def register_this_song(this_song)
  if @hash_songs_played
    this_song = File.basename(this_song)
    if @hash_songs_played.has_key? this_song
      @hash_songs_played[this_song] = @hash_songs_played[this_song] + 1
    else
      @hash_songs_played[this_song] = 1 # Initialize at 1 then.
    end
  end
end
register_which_song_was_last_played( this_song, store_where_to = the_songs_played_will_be_stored_where? ) click to toggle source
#

register_which_song_was_last_played

This method will also check if the file that is being played is too big. If it is, we will remove the log-file.

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 666
def register_which_song_was_last_played(
    this_song,
    store_where_to = the_songs_played_will_be_stored_where?
  )
  $stdout.flush # Unsure why we wish to do this.
  FileUtils.touch(store_where_to) unless File.exist?(store_where_to)
  if get_file_size(store_where_to) > MAXIMUM_ALLOWED_FILE_SIZE
    remove_file(store_where_to)
  end
  unless store_where_to.include? '/'
    store_where_to = HOME_DIRECTORY+store_where_to
  end # store_where_to now defaults to: /root/LAST_SONG_PLAYED
  append_what_into(this_song+N, store_where_to)
  register_this_song(this_song)
  # ======================================================================= #
  # Since as of September 2021 this class will also try to store into
  # a log file, if possible.
  # ======================================================================= #
  store_data_about_this_song_into_a_local_file(this_song)
end
register_which_song_will_be_played_next( this_song, store_where_to = the_songs_played_will_be_stored_where? )
report_which_audio_player_to_use() click to toggle source
#

report_which_audio_player_to_use

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 89
def report_which_audio_player_to_use
  opnn; e 'The audio player '+sfancy(@audio_player_to_use)+
          ' will be used.'
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method
# File lib/multimedia_paradise/audio/audio_player/reset.rb, line 14
def reset
  super()
  clear_playlist
  set_delay # Set @delay here.
  set_shall_we_exit
  # ======================================================================= #
  # === @namespace
  # ======================================================================= #
  @namespace = NAMESPACE
  # ======================================================================= #
  # === @use_colours
  # ======================================================================= #
  @use_colours = true # If true then we will use colours.
  # ======================================================================= #
  # === @main_colour
  # ======================================================================= #
  @main_colour = Colours.parse('green')
  # ======================================================================= #
  # === @play_in_a_loop
  # ======================================================================= #
  @play_in_a_loop = false
  determine_which_audio_player_to_use
  # ======================================================================= #
  # === @debug
  # ======================================================================= #
  @debug = SHALL_WE_DEBUG
  # ======================================================================= #
  # === @hash_songs_played
  # ======================================================================= #
  @hash_songs_played = {} # We keep track of all the files that we played.
  # ======================================================================= #
  # === @play_max_n_songs
  # ======================================================================= #
  @play_max_n_songs = PLAY_MAX_N_SONGS # Safeguard.
  if Object.const_defined? :MrxvtOptions
    @mrxvt = MrxvtOptions.new
  else
    @mrxvt = nil
  end
  # ======================================================================= #
  # === @use_oss_for_audio_player
  # ======================================================================= #
  @use_oss_for_audio_player = USE_OSS_FOR_AUDIO_PLAYER
  # ======================================================================= #
  # === @file_duration_in_seconds
  # ======================================================================= #
  @file_duration_in_seconds = 0 # Keeps the duration of the file in question.
  # ======================================================================= #
  # === @n_songs_played
  # ======================================================================= #
  @n_songs_played = 0 # How many songs we already played.
  # ======================================================================= #
  # === @available_genres
  # ======================================================================= #
  @available_genres = nil # Default.
  @available_genres = PLAYLIST_CONSTANTS.map {|song|
    song.to_s.sub(/GOOD_/,'').
              sub(/_SONGS/,'').
              sub(/MY_/,'').
              sub(/CURRENT_/,'')
  } if defined? PLAYLIST_CONSTANTS
end
reset_playlist() click to toggle source
#

reset_playlist

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 282
def reset_playlist
  @array_play_these_songs = [] # Keep all files that we wish to play in this Array.
end
Also aliased as: clear_playlist
return_all_songs() click to toggle source
#

return_all_songs

By default, we will shuffle.

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 262
def return_all_songs
  return AVAILABLE_SONGS.shuffle
end
return_random_song() click to toggle source
#

return_random_song

This method will return one random song.

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 274
def return_random_song
  return_all_songs.first
end
run() click to toggle source
#

run (run tag)

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 710
def run
  populate_hash_songs_played
  show_startup_message
  check_whether_the_song_directory_is_empty
  play_the_playlist
  perform_cleanup
end
sanitize_songs() click to toggle source
#

sanitize_songs

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 410
def sanitize_songs
  playlist?.flatten! # Always flatten it afterwards.
end
set_commandline_options_and_return_the_other_options(i) click to toggle source
#

set_commandline_options_and_return_the_other_options

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 108
def set_commandline_options_and_return_the_other_options(i)
  unless i.is_a? Symbol
    if i.respond_to?(:any?) and i.any? {|line|
        line.start_with? '--'
      }
      @commandline_options = i.select {|inner_line|
        inner_line.start_with? '--'
      }
      menu(@commandline_options)
      # ===================================================================== #
      # And finally, remove these entries that were found.
      # ===================================================================== #
      i.reject! {|entry|
        entry.start_with? '--'
      }
    end
  end
  i
end
set_delay(i = DEFAULT_DELAY_PLAYING_SONGS) click to toggle source
#

set_delay

This sets the default delay, when playing the audio songs in a loop.

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 147
def set_delay(i = DEFAULT_DELAY_PLAYING_SONGS)
  @delay = i
end
set_shall_we_exit(i = true) click to toggle source
#

set_shall_we_exit

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 165
def set_shall_we_exit(i = true)
  @shall_we_exit = i
end
shall_we_exit?() click to toggle source
#

shall_we_exit?

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 180
def shall_we_exit?
  @shall_we_exit
end
show_available_genres() click to toggle source
#

show_available_genres

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 172
def show_available_genres
  opnn; e 'The available genres are:'
  pp @available_genres
end
show_help( optional_shall_we_exit = false ) click to toggle source
#

show_help (help tag)

Show help here, then exit.

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 617
def show_help(
    optional_shall_we_exit = false
  )
  cliner
  opnn; e 'Showing the available help options next:'
  e
  colourized_comment '  - OPEN        # open this file in the editor'
  colourized_comment '  - loop        # play in an eternal loop'
  colourized_comment '  - rand        # play one random song'
  colourized_comment '  - once        # play all songs once, then quit'
  colourized_comment '  - last?       # show the last song played'
  colourized_comment '  - player?     # show which multimedia-player we will use'
  colourized_comment '  - log?        # show the log file of last-songs-played (if this file exists)'
  colourized_comment '  - last-songs? # show the last songs that '\
                     'were played, in a time-sorted manner'
  e
  cliner
  exit_program(true, false) if optional_shall_we_exit == :then_exit
end
show_last_file_played( _ = the_songs_played_will_be_stored_where? ) click to toggle source
#

show_last_file_played

This method will show the last song played.

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 189
def show_last_file_played(
    _ = the_songs_played_will_be_stored_where?
  )
  if File.exist? _
    e 'The last song played was:'
    efancy('  '+File.readlines(_)[-1])
    exit_program
  else
    ewarn 'But the file '+sfile(_)+RED+' does not exist.'
  end
end
show_songs()
Alias for: show_the_playlist
show_startup_message() click to toggle source
#

show_startup_message

Display a fancy startup message.

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 99
def show_startup_message
  e N+main_colour?+' => Starting Audio Player '+
    simp(use_which_audio_player?)+main_colour?+' ('+
    sfancy('Default delay: ')+delay?+mcol?+').'+N
end
show_the_last_songs_that_were_played() click to toggle source
#

show_the_last_songs_that_were_played

The songs played will be stored in a .md file.

Invocation example:

rsong --last-songs?
#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 697
def show_the_last_songs_that_were_played
  _ = the_songs_played_will_be_stored_where?
  if File.exist? _
    dataset = File.readlines(_)
    dataset.each {|this_song| e steelblue(this_song.strip) }
  else
    e 'No file exists at '+sfile(_)+'.'
  end
end
show_the_log_file_if_it_exists( log_file = THE_LOG_FILE_IS_STORED_HERE ) click to toggle source
#

show_the_log_file_if_it_exists

Invocation example:

rsong --log?
#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 581
def show_the_log_file_if_it_exists(
    log_file = THE_LOG_FILE_IS_STORED_HERE
  )
  if File.exist? log_file
    opnn; e 'Displaying the content of the file at'
    opnn; e '`'+sfile(log_file)+'`:'
    dataset = File.readlines(log_file).map {|entry| entry.rstrip } 
    e
    e mediumpurple(
        dataset.map {|entry| "  #{entry}" }.join("\n")
      )
  else
    opnn; e 'No file exists at '+sfile(log_file)+'.'
  end
end
show_the_playlist() click to toggle source
#

show_the_playlist

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 245
def show_the_playlist
  opnn; e 'The playlist is:'
  pp playlist?
end
Also aliased as: show_songs
shuffle()
shuffle_the_playlist() click to toggle source
#

shuffle_the_playlist

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 220
def shuffle_the_playlist
  playlist?.shuffle!
end
Also aliased as: shuffle
store_data_about_this_song_into_a_local_file( this_song ) click to toggle source
#

store_data_about_this_song_into_a_local_file

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 562
def store_data_about_this_song_into_a_local_file(
    this_song
  )
  into = THE_LOG_FILE_IS_STORED_HERE
  what = "song name: #{this_song.ljust(30)}, "\
         "played on #{dd_mm_yyyy}, #{hh_mm_ss}\n"
  dirname = File.dirname(into)
  mkdir(dirname) unless File.directory? dirname
  append_what_into(what, into)
end
the_songs_played_will_be_stored_where?() click to toggle source
#

the_songs_played_will_be_stored_where?

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 204
def the_songs_played_will_be_stored_where?
  FULL_LOCATION_FOR_LAST_SONG_PLAYED
end
try_to_find_genre_song(i) click to toggle source
#

try_to_find_genre_song

This tries to find a (random) genre song.

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 469
def try_to_find_genre_song(i)
  upcased = i.to_s.upcase
  if @available_genres.grep(/#{upcased}/)
    matches = PLAYLIST_CONSTANTS.select {|entry| entry =~ /#{upcased}/ }[0]
    if matches.nil? # Then try without playlist
      these_songs = Dir[audio_dir?+'*'+i+'*']
    end
    these_songs = PlaylistProfile.module_eval(matches.to_s).map {|entry|
      audio_dir?+entry
    } if matches
    add_song(these_songs.shuffle)
  end if @available_genres
end
try_to_play_playlist() click to toggle source
#

try_to_play_playlist

#
# File lib/multimedia_paradise/audio/audio_player/misc.rb, line 234
def try_to_play_playlist
  begin
    require 'x/AUD/playlist.rb'
    add(Playlist.playlist?)
    shuffle
  rescue LoadError; end
end
use_which_audio_player?()