Changeset 352 for CoolAudio/UPlaylist.pas
- Timestamp:
- Apr 23, 2012, 1:32:52 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
CoolAudio/UPlaylist.pas
r347 r352 6 6 7 7 uses 8 Classes, SysUtils, Contnrs ;8 Classes, SysUtils, Contnrs, UAudioSystem; 9 9 10 10 type 11 11 TPlaylistItem = class 12 12 FileName: string; 13 13 end; 14 14 … … 16 16 17 17 TPlaylist = class(TComponent) 18 public 19 Player: TPlayer; 18 20 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; 19 29 constructor Create(AOwner: TComponent); 20 30 destructor Destroy; override; … … 25 35 26 36 { TPlaylist } 37 38 procedure TPlaylist.AddFile(FileName: string); 39 var 40 NewItem: TPlaylistItem; 41 begin 42 NewItem := TPlaylistItem.Create; 43 NewItem.FileName := FileName; 44 Items.Add(NewItem); 45 end; 46 47 procedure TPlaylist.Shuffle; 48 begin 49 50 end; 51 52 procedure TPlaylist.Play; 53 begin 54 Player.FileName := TPlaylistItem(Items[CurrentIndex]).FileName; 55 Player.Play; 56 end; 57 58 procedure TPlaylist.PlayNext; 59 begin 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; 67 end; 68 69 procedure TPlaylist.PlayPrevious; 70 begin 71 Dec(CurrentIndex); 72 if CurrentIndex < 0 then begin 73 CurrentIndex := Items.Count - 1; 74 end; 75 Play; 76 end; 27 77 28 78 constructor TPlaylist.Create(AOwner: TComponent);
Note:
See TracChangeset
for help on using the changeset viewer.