Ignore:
Timestamp:
Apr 23, 2012, 1:32:52 PM (12 years ago)
Author:
chronos
Message:
  • Modified: Supported AudioSystems is configured using include config file.
  • Added: Added playlist demo to Demo player.
  • Added: Working DSP audiosystem for playing using linux /dev/dsp device. DSP backend support only WAV file so far.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • CoolAudio/UPlaylist.pas

    r347 r352  
    66
    77uses
    8   Classes, SysUtils, Contnrs;
     8  Classes, SysUtils, Contnrs, UAudioSystem;
    99
    1010type
    1111  TPlaylistItem = class
    12 
     12    FileName: string;
    1313  end;
    1414
     
    1616
    1717  TPlaylist = class(TComponent)
     18  public
     19    Player: TPlayer;
    1820    Items: TObjectList; // TObjectList<TPlaylistItem>
     21    RandomOrder: Boolean;
     22    RepeatInfinitely: Boolean;
     23    CurrentIndex: Integer;
     24    procedure AddFile(FileName: string);
     25    procedure Shuffle;
     26    procedure Play;
     27    procedure PlayNext;
     28    procedure PlayPrevious;
    1929    constructor Create(AOwner: TComponent);
    2030    destructor Destroy; override;
     
    2535
    2636{ TPlaylist }
     37
     38procedure TPlaylist.AddFile(FileName: string);
     39var
     40  NewItem: TPlaylistItem;
     41begin
     42  NewItem := TPlaylistItem.Create;
     43  NewItem.FileName := FileName;
     44  Items.Add(NewItem);
     45end;
     46
     47procedure TPlaylist.Shuffle;
     48begin
     49
     50end;
     51
     52procedure TPlaylist.Play;
     53begin
     54  Player.FileName := TPlaylistItem(Items[CurrentIndex]).FileName;
     55  Player.Play;
     56end;
     57
     58procedure TPlaylist.PlayNext;
     59begin
     60  Inc(CurrentIndex);
     61  if CurrentIndex >= Items.Count then begin
     62    CurrentIndex := 0;
     63    if RandomOrder then Shuffle;
     64    if not RepeatInfinitely then Player.Stop;
     65  end;
     66  Play;
     67end;
     68
     69procedure TPlaylist.PlayPrevious;
     70begin
     71  Dec(CurrentIndex);
     72  if CurrentIndex < 0 then begin
     73    CurrentIndex := Items.Count - 1;
     74  end;
     75  Play;
     76end;
    2777
    2878constructor TPlaylist.Create(AOwner: TComponent);
Note: See TracChangeset for help on using the changeset viewer.