Skip to content
ggodart edited this page Jan 1, 2021 · 2 revisions

PlayList

See original

SYNOPSIS

Note that you can have as many AlsaPlayer objects as you want but each one must have a unique alsa device name.

  use AlsaPlayer;
  my $mp3_player = new AlsaPlayer('alsa_device_name');

  use PlayList;
  my $kirk_mp3s = new PlayList;

  if ($Startup) {
     # Starts the Alsaplayer process
     $mp3_player->start();

     # Populate the playlist
     $kirk_mp3s->add_files('/mnt/mp3s/KirkAll.m3u');
     $kirk_mp3s->add_files('/mnt/mp3s/blah/blah.mp3');
     $kirk_mp3s->add_files('/mnt/mp3s/favorites/');

     # Start playing the MP3s
     $mp3_player->add_playlist($kirk_mp3s);
     $mp3_player->unpause();
  }

If you want randomized playlist, you can call the randomize() function on the PlayList object before adding it to the player but after populating it with MP3s. Instead (or in addition to), you can call shuffle(1) on AlsaPlayer before adding any playlists. This requires you to have patched your AlsaPlayer as described just above the shuffle function in this module.

DESCRIPTION

Object containing a list of music files. Currently supports:

  1. MP3 files
  2. M3U files contaning lists of MP3 files
  3. Directories containing MP3 files Currently used by AlsaPlayer.pm on Linux. Changes to the playlist are passed along to any AlsaPlayers that have the playlist currently attached.

You can get the most current version of this file and other files related whole-house music/speech setup here:

http://www.linux.kaybee.org:81/tabs/whole_house_audio/

INHERITS

NONE

METHODS

Method Description
add_files(list) Adds one or more .mp3, .m3u and/or directories to this playlist object (and any players with this object attached).
add_mp3_files(list) Adds one or more .mp3 files and/or directories to this playlist object (and any players with this object attached).
add_m3u_files(list) Adds the contents of any m3u files that are specified or that are found in a directory (recursively) that was specified.
remove_files(list) Removes one or more .mp3, .m3u and/or directories from this playlist object (and any players with this object attached).
clear() Empties this playlist.
randomize_by_dir() Call only after you have added your MP3s... randomizes the order of songs by directory -- i.e. first it determines all of the directories, and then randomly picks one, and then another, etc. Note that the MP3 list is sorted in this process, so I'd recomment beginning your MP3 names with the track number on each CD -- i.e. 01-xx.mp3. I use this to basically sort by directory.
randomize() Call only after you have added your MP3s... randomizes the order of all songs currently in the playlist.

INI PARAMETERS

NONE

AUTHOR

Kirk Bauer [email protected]

Special Thanks to: Bruce Winter - Misterhouse

SEE ALSO

AlsaPlayer

Clone this wiki locally