You've already forked lazarus-ccr
Fixes the UTF8 bugs of MP3 detail.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1771 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -604,18 +604,22 @@ object Main: TMain
|
|||||||
item
|
item
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
Caption = 'Title'
|
Caption = 'Title'
|
||||||
|
Width = 37
|
||||||
end
|
end
|
||||||
item
|
item
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
Caption = 'Album'
|
Caption = 'Album'
|
||||||
|
Width = 52
|
||||||
end
|
end
|
||||||
item
|
item
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
Caption = 'Track'
|
Caption = 'Track'
|
||||||
|
Width = 45
|
||||||
end
|
end
|
||||||
item
|
item
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
Caption = 'Genre'
|
Caption = 'Genre'
|
||||||
|
Width = 49
|
||||||
end
|
end
|
||||||
item
|
item
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
@ -627,7 +631,7 @@ object Main: TMain
|
|||||||
AutoSize = True
|
AutoSize = True
|
||||||
Caption = 'Length'
|
Caption = 'Length'
|
||||||
MaxWidth = 60
|
MaxWidth = 60
|
||||||
Width = 57
|
Width = 55
|
||||||
end>
|
end>
|
||||||
PopupMenu = titlelistmenu
|
PopupMenu = titlelistmenu
|
||||||
ReadOnly = True
|
ReadOnly = True
|
||||||
@ -843,7 +847,7 @@ object Main: TMain
|
|||||||
end
|
end
|
||||||
object current_title_edit: TEdit
|
object current_title_edit: TEdit
|
||||||
Left = 12
|
Left = 12
|
||||||
Height = 21
|
Height = 27
|
||||||
Top = 109
|
Top = 109
|
||||||
Width = 200
|
Width = 200
|
||||||
Color = clBtnFace
|
Color = clBtnFace
|
||||||
@ -852,7 +856,7 @@ object Main: TMain
|
|||||||
end
|
end
|
||||||
object current_title_edit1: TEdit
|
object current_title_edit1: TEdit
|
||||||
Left = 12
|
Left = 12
|
||||||
Height = 21
|
Height = 27
|
||||||
Top = 141
|
Top = 141
|
||||||
Width = 200
|
Width = 200
|
||||||
Color = clBtnFace
|
Color = clBtnFace
|
||||||
@ -861,9 +865,9 @@ object Main: TMain
|
|||||||
end
|
end
|
||||||
object randomcheck: TCheckBox
|
object randomcheck: TCheckBox
|
||||||
Left = 135
|
Left = 135
|
||||||
Height = 19
|
Height = 23
|
||||||
Top = 257
|
Top = 257
|
||||||
Width = 62
|
Width = 75
|
||||||
Caption = 'Random'
|
Caption = 'Random'
|
||||||
OnChange = randomcheckChange
|
OnChange = randomcheckChange
|
||||||
TabOrder = 3
|
TabOrder = 3
|
||||||
@ -946,10 +950,10 @@ object Main: TMain
|
|||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
object filetypebox: TComboBox
|
object filetypebox: TComboBox
|
||||||
Left = 360
|
Left = 360
|
||||||
Height = 21
|
Height = 27
|
||||||
Top = 14
|
Top = 14
|
||||||
Width = 90
|
Width = 90
|
||||||
ItemHeight = 13
|
ItemHeight = 19
|
||||||
ItemIndex = 0
|
ItemIndex = 0
|
||||||
Items.Strings = (
|
Items.Strings = (
|
||||||
'all types'
|
'all types'
|
||||||
@ -967,7 +971,7 @@ object Main: TMain
|
|||||||
end
|
end
|
||||||
object searchstr: TEdit
|
object searchstr: TEdit
|
||||||
Left = 120
|
Left = 120
|
||||||
Height = 21
|
Height = 27
|
||||||
Top = 14
|
Top = 14
|
||||||
Width = 232
|
Width = 232
|
||||||
OnKeyUp = searchstrKeyUp
|
OnKeyUp = searchstrKeyUp
|
||||||
@ -977,7 +981,7 @@ object Main: TMain
|
|||||||
Left = 16
|
Left = 16
|
||||||
Height = 28
|
Height = 28
|
||||||
Hint = 'Search the library'
|
Hint = 'Search the library'
|
||||||
Top = 10
|
Top = 12
|
||||||
Width = 90
|
Width = 90
|
||||||
BorderSpacing.InnerBorder = 4
|
BorderSpacing.InnerBorder = 4
|
||||||
Caption = 'Search'
|
Caption = 'Search'
|
||||||
@ -1012,7 +1016,7 @@ object Main: TMain
|
|||||||
Left = 501
|
Left = 501
|
||||||
Height = 30
|
Height = 30
|
||||||
Hint = 'Clear Playlist'
|
Hint = 'Clear Playlist'
|
||||||
Top = 12
|
Top = 14
|
||||||
Width = 84
|
Width = 84
|
||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
@ -1196,7 +1200,7 @@ object Main: TMain
|
|||||||
end
|
end
|
||||||
object artistsearch: TEdit
|
object artistsearch: TEdit
|
||||||
Left = 8
|
Left = 8
|
||||||
Height = 21
|
Height = 27
|
||||||
Top = 32
|
Top = 32
|
||||||
Width = 110
|
Width = 110
|
||||||
OnKeyUp = ArtistTreeKeyUp
|
OnKeyUp = ArtistTreeKeyUp
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -15,7 +15,7 @@
|
|||||||
<AutoIncrementBuild Value="True"/>
|
<AutoIncrementBuild Value="True"/>
|
||||||
<MinorVersionNr Value="3"/>
|
<MinorVersionNr Value="3"/>
|
||||||
<RevisionNr Value="5"/>
|
<RevisionNr Value="5"/>
|
||||||
<BuildNr Value="738"/>
|
<BuildNr Value="739"/>
|
||||||
<StringTable ProductVersion="0.3.5.737"/>
|
<StringTable ProductVersion="0.3.5.737"/>
|
||||||
</VersionInfo>
|
</VersionInfo>
|
||||||
<BuildModes Count="1">
|
<BuildModes Count="1">
|
||||||
|
@ -10,46 +10,49 @@ uses
|
|||||||
|
|
||||||
{ TPlaylistitemClass }
|
{ TPlaylistitemClass }
|
||||||
type
|
type
|
||||||
TPlaylistitemClass = class
|
TPlaylistitemClass = class
|
||||||
Artist, Title, Path, Album: string;
|
Artist, Title, Path, Album: string;
|
||||||
LengthMS, id:longint;
|
LengthMS, id: longint;
|
||||||
Played: boolean;
|
Played: boolean;
|
||||||
constructor create;
|
constructor Create;
|
||||||
destructor destroy;
|
destructor Destroy;
|
||||||
procedure update(MedFileObj: TMediaFileClass);
|
procedure update(MedFileObj: TMediaFileClass);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
PPlaylistItemClass = ^TPlaylistitemClass;
|
PPlaylistItemClass = ^TPlaylistitemClass;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
{ TPlaylistClass }
|
{ TPlaylistClass }
|
||||||
|
|
||||||
TPlaylistClass = class(Tlist)
|
TPlaylistClass = class(TList)
|
||||||
private
|
private
|
||||||
function GetItems(index: integer):TPlaylistitemClass;
|
function GetItems(index: integer): TPlaylistitemClass;
|
||||||
public
|
public
|
||||||
CurrentTrack: integer;
|
CurrentTrack: integer;
|
||||||
property Items[index: integer]: TPlaylistitemClass read GetItems;
|
property Items[index: integer]: TPlaylistitemClass read GetItems;
|
||||||
|
|
||||||
constructor create;
|
constructor Create;
|
||||||
destructor destroy;
|
destructor Destroy;
|
||||||
function TotalPlayTime: int64;
|
function TotalPlayTime: int64;
|
||||||
function TotalPlayTimeStr: string;
|
function TotalPlayTimeStr: string;
|
||||||
procedure move(dest, target:integer);
|
procedure move(dest, target: integer);
|
||||||
procedure remove(index: integer);
|
procedure remove(index: integer);
|
||||||
procedure clear; override;
|
procedure Clear; override;
|
||||||
function add(filepath:string):integer; //Read track info out of file at path
|
function add(filepath: string): integer; //Read track info out of file at path
|
||||||
function add(MedFileObj: TMediaFileClass):integer; //Get track info from FileObj
|
function add(MedFileObj: TMediaFileClass): integer; //Get track info from FileObj
|
||||||
procedure insert(index:integer; MedFileObj: TMediaFileClass);
|
procedure insert(index: integer; MedFileObj: TMediaFileClass);
|
||||||
|
|
||||||
function update(index: integer; filepath:string):integer; //update track info out of file at path
|
function update(index: integer; filepath: string): integer;
|
||||||
function update(index: integer; MedFileObj: TMediaFileClass):integer; //update track info from FileObj
|
//update track info out of file at path
|
||||||
function RandomIndex:integer;
|
function update(index: integer; MedFileObj: TMediaFileClass): integer;
|
||||||
|
//update track info from FileObj
|
||||||
|
function RandomIndex: integer;
|
||||||
procedure reset_random;
|
procedure reset_random;
|
||||||
function ItemCount:integer;
|
function ItemCount: integer;
|
||||||
function LoadFromFile(path:string):byte;
|
function LoadFromFile(path: string): byte;
|
||||||
function SaveToFile(path:string):byte;
|
function SaveToFile(path: string): byte;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
@ -60,14 +63,14 @@ implementation
|
|||||||
{ TPlaylistitemClass }
|
{ TPlaylistitemClass }
|
||||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
constructor TPlaylistitemClass.create;
|
constructor TPlaylistitemClass.Create;
|
||||||
begin
|
begin
|
||||||
played:=false;
|
played := False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
destructor TPlaylistitemClass.destroy;
|
destructor TPlaylistitemClass.Destroy;
|
||||||
begin
|
begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -76,12 +79,12 @@ end;
|
|||||||
procedure TPlaylistitemClass.update(MedFileObj: TMediaFileClass);
|
procedure TPlaylistitemClass.update(MedFileObj: TMediaFileClass);
|
||||||
begin
|
begin
|
||||||
|
|
||||||
Artist:=MedFileObj.Artist;
|
Artist := MedFileObj.Artist;
|
||||||
Title:=MedFileObj.Title;
|
Title := MedFileObj.Title;
|
||||||
Album:=MedFileObj.Album;
|
Album := MedFileObj.Album;
|
||||||
|
|
||||||
ID:=MedFileObj.ID;
|
ID := MedFileObj.ID;
|
||||||
LengthMS:=MedFileObj.Playlength;
|
LengthMS := MedFileObj.Playlength;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -91,67 +94,80 @@ end;
|
|||||||
|
|
||||||
function TPlaylistClass.GetItems(index: integer): TPlaylistitemClass;
|
function TPlaylistClass.GetItems(index: integer): TPlaylistitemClass;
|
||||||
begin
|
begin
|
||||||
if (index>=0) and (index < Count) then Result := (TPlaylistitemClass(Inherited Items [Index]));
|
if (index >= 0) and (index < Count) then
|
||||||
|
Result := (TPlaylistitemClass(inherited Items[Index]));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
constructor TPlaylistClass.create;
|
constructor TPlaylistClass.Create;
|
||||||
begin
|
begin
|
||||||
Inherited create;
|
inherited Create;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TPlaylistClass.destroy;
|
destructor TPlaylistClass.Destroy;
|
||||||
begin
|
begin
|
||||||
clear;
|
Clear;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
function TPlaylistClass.TotalPlayTime: int64; // returns total playtime of playlist in milliseconds
|
function TPlaylistClass.TotalPlayTime: int64;
|
||||||
var i: integer;
|
// returns total playtime of playlist in milliseconds
|
||||||
|
var
|
||||||
|
i: integer;
|
||||||
PPlaylistItem: PPlaylistItemClass;
|
PPlaylistItem: PPlaylistItemClass;
|
||||||
begin
|
begin
|
||||||
result:=0;
|
Result := 0;
|
||||||
for i:= 0 to Count-1 do begin
|
for i := 0 to Count - 1 do
|
||||||
result:=result + Items[i].LengthMS;
|
begin
|
||||||
|
Result := Result + Items[i].LengthMS;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
function TPlaylistClass.TotalPlayTimeStr: string; // returns total playtime of playlist in string
|
function TPlaylistClass.TotalPlayTimeStr: string;
|
||||||
|
// returns total playtime of playlist in string
|
||||||
// format. i.e. '2h 20min'
|
// format. i.e. '2h 20min'
|
||||||
var s1,s2: string;
|
var
|
||||||
|
s1, s2: string;
|
||||||
i: int64;
|
i: int64;
|
||||||
begin
|
begin
|
||||||
i:=TotalPlayTime;
|
i := TotalPlayTime;
|
||||||
s2:=IntToStr((i div 60) mod 60 );
|
s2 := IntToStr((i div 60) mod 60);
|
||||||
s1:=IntToStr((i div 60) div 60 );
|
s1 := IntToStr((i div 60) div 60);
|
||||||
result:=s1+'h '+s2+'min';
|
Result := s1 + 'h ' + s2 + 'min';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
procedure TPlaylistClass.move(dest, target: integer);
|
procedure TPlaylistClass.move(dest, target: integer);
|
||||||
var current_track_tmp: integer;
|
var
|
||||||
|
current_track_tmp: integer;
|
||||||
begin
|
begin
|
||||||
if (dest < ItemCount) and (target < ItemCount) and (dest >= 0) and (target >= 0 ) then
|
if (dest < ItemCount) and (target < ItemCount) and (dest >= 0) and (target >= 0) then
|
||||||
begin
|
begin
|
||||||
inherited Move(dest, target);
|
inherited Move(dest, target);
|
||||||
current_track_tmp:= CurrentTrack;
|
current_track_tmp := CurrentTrack;
|
||||||
if (CurrentTrack>dest) and (CurrentTrack<=target+1) then dec(current_track_tmp);
|
if (CurrentTrack > dest) and (CurrentTrack <= target + 1) then
|
||||||
|
Dec(current_track_tmp);
|
||||||
|
|
||||||
if (CurrentTrack<dest) and (CurrentTrack>=target) then inc(current_track_tmp);
|
if (CurrentTrack < dest) and (CurrentTrack >= target) then
|
||||||
|
Inc(current_track_tmp);
|
||||||
|
|
||||||
if (CurrentTrack=dest) then begin
|
if (CurrentTrack = dest) then
|
||||||
current_track_tmp:=target;
|
begin
|
||||||
|
current_track_tmp := target;
|
||||||
// if dest<target then current_track_tmp:=target+1 else current_track_tmp:=target;
|
// if dest<target then current_track_tmp:=target+1 else current_track_tmp:=target;
|
||||||
end;
|
end;
|
||||||
write('dest');writeln(dest);
|
Write('dest');
|
||||||
write('target');writeln(target);
|
writeln(dest);
|
||||||
write('curtrack_before');writeln(CurrentTrack);
|
Write('target');
|
||||||
CurrentTrack:=current_track_tmp;
|
writeln(target);
|
||||||
|
Write('curtrack_before');
|
||||||
|
writeln(CurrentTrack);
|
||||||
|
CurrentTrack := current_track_tmp;
|
||||||
|
|
||||||
writeln(CurrentTrack);
|
writeln(CurrentTrack);
|
||||||
end;
|
end;
|
||||||
@ -161,19 +177,22 @@ end;
|
|||||||
|
|
||||||
procedure TPlaylistClass.remove(index: integer);
|
procedure TPlaylistClass.remove(index: integer);
|
||||||
begin
|
begin
|
||||||
if (index>=0) and (index < Count) then begin
|
if (index >= 0) and (index < Count) then
|
||||||
Items[index].free;
|
begin
|
||||||
|
Items[index].Free;
|
||||||
inherited Delete(index);
|
inherited Delete(index);
|
||||||
if CurrentTrack>index then dec(CurrentTrack);
|
if CurrentTrack > index then
|
||||||
|
Dec(CurrentTrack);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
procedure TPlaylistClass.clear;
|
procedure TPlaylistClass.Clear;
|
||||||
begin
|
begin
|
||||||
while count>0 do remove(0);
|
while Count > 0 do
|
||||||
CurrentTrack:=-1;
|
remove(0);
|
||||||
|
CurrentTrack := -1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
@ -185,37 +204,39 @@ end;
|
|||||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
function TPlaylistClass.add(MedFileObj: TMediaFileClass): integer;
|
function TPlaylistClass.add(MedFileObj: TMediaFileClass): integer;
|
||||||
var Playlistitem: TPlaylistitemClass;
|
var
|
||||||
|
Playlistitem: TPlaylistitemClass;
|
||||||
index: integer;
|
index: integer;
|
||||||
begin
|
begin
|
||||||
|
|
||||||
index:=(inherited Add(TPlaylistitemClass.create));
|
index := (inherited Add(TPlaylistitemClass.Create));
|
||||||
|
|
||||||
|
|
||||||
Items[index].Path:=MedFileObj.path;
|
Items[index].Path := MedFileObj.path;
|
||||||
Items[index].Artist:=MedFileObj.Artist;
|
Items[index].Artist := MedFileObj.Artist;
|
||||||
Items[index].Title:=MedFileObj.Title;
|
Items[index].Title := MedFileObj.Title;
|
||||||
Items[index].Album:=MedFileObj.Album;
|
Items[index].Album := MedFileObj.Album;
|
||||||
|
|
||||||
Items[index].ID:=MedFileObj.ID;
|
Items[index].ID := MedFileObj.ID;
|
||||||
Items[index].LengthMS:=MedFileObj.Playlength;
|
Items[index].LengthMS := MedFileObj.Playlength;
|
||||||
result:=index;
|
Result := index;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
procedure TPlaylistClass.insert(index: integer; MedFileObj: TMediaFileClass);
|
procedure TPlaylistClass.insert(index: integer; MedFileObj: TMediaFileClass);
|
||||||
begin
|
begin
|
||||||
inherited insert(index, TPlaylistitemClass.create);
|
inherited insert(index, TPlaylistitemClass.Create);
|
||||||
|
|
||||||
Items[index].Path:=MedFileObj.path;
|
Items[index].Path := MedFileObj.path;
|
||||||
Items[index].Artist:=MedFileObj.Artist;
|
Items[index].Artist := MedFileObj.Artist;
|
||||||
Items[index].Title:=MedFileObj.Title;
|
Items[index].Title := MedFileObj.Title;
|
||||||
Items[index].Album:=MedFileObj.Album;
|
Items[index].Album := MedFileObj.Album;
|
||||||
|
|
||||||
Items[index].ID:=MedFileObj.ID;
|
Items[index].ID := MedFileObj.ID;
|
||||||
Items[index].LengthMS:=MedFileObj.Playlength;
|
Items[index].LengthMS := MedFileObj.Playlength;
|
||||||
if index<CurrentTrack then inc(CurrentTrack);
|
if index < CurrentTrack then
|
||||||
|
Inc(CurrentTrack);
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -230,7 +251,8 @@ end;
|
|||||||
|
|
||||||
function TPlaylistClass.update(index: integer; MedFileObj: TMediaFileClass): integer;
|
function TPlaylistClass.update(index: integer; MedFileObj: TMediaFileClass): integer;
|
||||||
begin
|
begin
|
||||||
if (index>=0) and (index<Count) then begin
|
if (index >= 0) and (index < Count) then
|
||||||
|
begin
|
||||||
|
|
||||||
Items[index].update(MedFileObj);
|
Items[index].update(MedFileObj);
|
||||||
end;
|
end;
|
||||||
@ -239,115 +261,136 @@ end;
|
|||||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
function TPlaylistClass.RandomIndex: integer;
|
function TPlaylistClass.RandomIndex: integer;
|
||||||
// Returns a random index of playlist entry that has not been played yet. -1 if all has been played.
|
// Returns a random index of playlist entry that has not been played yet. -1 if all has been played.
|
||||||
// reset_random resets it
|
// reset_random resets it
|
||||||
var x, i:integer;
|
var
|
||||||
|
x, i: integer;
|
||||||
s: boolean;
|
s: boolean;
|
||||||
begin
|
begin
|
||||||
s := false;
|
s := False;
|
||||||
for i := 0 to Count-1 do if Items[i].played=false then s:= true;
|
for i := 0 to Count - 1 do
|
||||||
|
if Items[i].played = False then
|
||||||
|
s := True;
|
||||||
randomize;
|
randomize;
|
||||||
if s then begin
|
if s then
|
||||||
i:=0;
|
begin
|
||||||
repeat begin
|
i := 0;
|
||||||
x:=random(Count-1);
|
repeat
|
||||||
inc(i);
|
begin
|
||||||
|
x := random(Count - 1);
|
||||||
|
Inc(i);
|
||||||
end;
|
end;
|
||||||
until (Items[x].played=false) or (i > 4096); // i is for timeout to prevent an endless loop
|
until (Items[x].played = False) or (i > 4096);
|
||||||
|
// i is for timeout to prevent an endless loop
|
||||||
|
|
||||||
if i>4096 then begin
|
if i > 4096 then
|
||||||
x:=-1;
|
begin
|
||||||
repeat inc(x) until Items[x].played=false;
|
x := -1;
|
||||||
|
repeat
|
||||||
|
Inc(x)
|
||||||
|
until Items[x].played = False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
result:=x;
|
Result := x;
|
||||||
end
|
end
|
||||||
else begin
|
else
|
||||||
result:=-1;
|
begin
|
||||||
|
Result := -1;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
procedure TPlaylistClass.reset_random;
|
procedure TPlaylistClass.reset_random;
|
||||||
var i: integer;
|
var
|
||||||
|
i: integer;
|
||||||
begin
|
begin
|
||||||
for i:= 0 to Count-1 do Items[i].played:=false;
|
for i := 0 to Count - 1 do
|
||||||
|
Items[i].played := False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
function TPlaylistClass.ItemCount: integer;
|
function TPlaylistClass.ItemCount: integer;
|
||||||
begin
|
begin
|
||||||
result:=inherited Count;
|
Result := inherited Count;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
function TPlaylistClass.LoadFromFile(path: string): byte; //Load .m3u Playlist
|
function TPlaylistClass.LoadFromFile(path: string): byte; //Load .m3u Playlist
|
||||||
var s, tmps, fpath, fartist, ftitle:string;
|
var
|
||||||
pos1,pos2, i, lengthS:integer;
|
s, tmps, fpath, fartist, ftitle: string;
|
||||||
|
pos1, pos2, i, lengthS: integer;
|
||||||
PlaylistItem: TPlaylistItemClass;
|
PlaylistItem: TPlaylistItemClass;
|
||||||
fileobj: TMediaFileClass;
|
fileobj: TMediaFileClass;
|
||||||
filehandle:text;
|
filehandle: Text;
|
||||||
begin
|
begin
|
||||||
try
|
try
|
||||||
system.assign(Filehandle,path);
|
system.Assign(Filehandle, path);
|
||||||
Reset(filehandle);
|
Reset(filehandle);
|
||||||
readln(filehandle, tmps);
|
readln(filehandle, tmps);
|
||||||
if pos('#EXTM3U',tmps)<>0 then begin
|
if pos('#EXTM3U', tmps) <> 0 then
|
||||||
repeat begin
|
begin
|
||||||
repeat readln(filehandle, tmps) until ((pos('#EXTINF', tmps)<>0) or eof(filehandle));
|
repeat
|
||||||
pos1:=pos(':', tmps)+1;
|
begin
|
||||||
pos2:=pos(',', tmps);
|
repeat
|
||||||
s:=copy(tmps,pos1,pos2-pos1);
|
readln(filehandle, tmps)
|
||||||
|
until ((pos('#EXTINF', tmps) <> 0) or EOF(filehandle));
|
||||||
|
pos1 := pos(':', tmps) + 1;
|
||||||
|
pos2 := pos(',', tmps);
|
||||||
|
s := copy(tmps, pos1, pos2 - pos1);
|
||||||
|
|
||||||
val(s,LengthS);
|
val(s, LengthS);
|
||||||
|
|
||||||
pos1:=pos2+1;
|
pos1 := pos2 + 1;
|
||||||
pos2:=pos(' - ',tmps);
|
pos2 := pos(' - ', tmps);
|
||||||
|
|
||||||
fartist:=copy(tmps,pos1,pos2-pos1);
|
fartist := copy(tmps, pos1, pos2 - pos1);
|
||||||
pos2:=pos2+3;
|
pos2 := pos2 + 3;
|
||||||
ftitle:=copy(tmps,pos2,(length(tmps))-pos2+1);
|
ftitle := copy(tmps, pos2, (length(tmps)) - pos2 + 1);
|
||||||
readln(filehandle, fpath);
|
readln(filehandle, fpath);
|
||||||
|
|
||||||
i:=(inherited Add(TPlaylistitemClass.create));
|
i := (inherited Add(TPlaylistitemClass.Create));
|
||||||
Items[i].Title:=ftitle;
|
Items[i].Title := ftitle;
|
||||||
Items[i].Artist:=fartist;
|
Items[i].Artist := fartist;
|
||||||
Items[i].Path:=fpath;
|
Items[i].Path := fpath;
|
||||||
Items[i].LengthMS:=lengthS*1000;
|
Items[i].LengthMS := lengthS * 1000;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
until eof(filehandle);
|
until EOF(filehandle);
|
||||||
end else debugoutln(path+' is not a valid m3u playlist',4);
|
end
|
||||||
close(filehandle);
|
else
|
||||||
result:=0;
|
debugoutln(path + ' is not a valid m3u playlist', 4);
|
||||||
|
Close(filehandle);
|
||||||
|
Result := 0;
|
||||||
except
|
except
|
||||||
result:=1;
|
Result := 1;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
function TPlaylistClass.SaveToFile(path: string): byte;
|
function TPlaylistClass.SaveToFile(path: string): byte;
|
||||||
var i:integer;
|
var
|
||||||
|
i: integer;
|
||||||
temps: string;
|
temps: string;
|
||||||
filehandle:text;
|
filehandle: Text;
|
||||||
begin
|
begin
|
||||||
try
|
try
|
||||||
system.assign(Filehandle,path);
|
system.Assign(Filehandle, path);
|
||||||
Rewrite(filehandle);
|
Rewrite(filehandle);
|
||||||
writeln(Filehandle,'#EXTM3U');
|
writeln(Filehandle, '#EXTM3U');
|
||||||
for i:= 0 to Count-1 do begin
|
for i := 0 to Count - 1 do
|
||||||
|
begin
|
||||||
str(Items[i].LengthMS div 1000, temps);
|
str(Items[i].LengthMS div 1000, temps);
|
||||||
writeln(filehandle,'#EXTINF:'+temps+','+Items[i].artist+' - '+Items[i].title);
|
writeln(filehandle, '#EXTINF:' + temps + ',' + Items[i].artist + ' - ' + Items[i].title);
|
||||||
writeln(filehandle, Items[i].path);
|
writeln(filehandle, Items[i].path);
|
||||||
end;
|
end;
|
||||||
close(filehandle);
|
Close(filehandle);
|
||||||
result:=0;
|
Result := 0;
|
||||||
except
|
except
|
||||||
result:=1;
|
Result := 1;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -285,10 +285,24 @@ Begin
|
|||||||
ftrack := '';
|
ftrack := '';
|
||||||
End; // else writeln('no id3v1 tag');
|
End; // else writeln('no id3v1 tag');
|
||||||
except WriteLn(Filename+' -> exception while reading id3v1 tag... skipped!!'); end;
|
except WriteLn(Filename+' -> exception while reading id3v1 tag... skipped!!'); end;
|
||||||
If ((artistv2<>'')) And (CactusConfig.id3v2_prio Or (artist='')) Then Fartist := artistv2;
|
{ If ((artistv2<>'')) And (CactusConfig.id3v2_prio Or (artist='')) Then Fartist := artistv2;
|
||||||
If ((titlev2<>'')) And (CactusConfig.id3v2_prio Or (title='')) Then Ftitle := titlev2;
|
If ((titlev2<>'')) And (CactusConfig.id3v2_prio Or (title='')) Then Ftitle := titlev2;
|
||||||
If ((albumv2<>'')) And (CactusConfig.id3v2_prio Or (album='')) Then Falbum := albumv2;
|
If ((albumv2<>'')) And (CactusConfig.id3v2_prio Or (album='')) Then Falbum := albumv2;
|
||||||
If ((commentv2<>'')) And (CactusConfig.id3v2_prio Or (comment='')) Then Fcomment := commentv2;
|
If ((commentv2<>'')) And (CactusConfig.id3v2_prio Or (comment='')) Then Fcomment := commentv2; }
|
||||||
|
{$IFDEF WINDOWS}
|
||||||
|
if Length(Trim(fartist)) <> 0 then begin
|
||||||
|
If ((artistv2<>'')) And (CactusConfig.id3v2_prio Or (artist='')) Then Fartist := UTF8Encode(artistv2);
|
||||||
|
end else Fartist := artistv2;
|
||||||
|
if Length(Trim(Ftitle)) <> 0 then begin
|
||||||
|
If ((titlev2<>'')) And (CactusConfig.id3v2_prio Or (title='')) Then Ftitle := UTF8Encode(titlev2);
|
||||||
|
end else Ftitle := titlev2;
|
||||||
|
if Length(Trim(Falbum)) <> 0 then begin
|
||||||
|
If ((albumv2<>'')) And (CactusConfig.id3v2_prio Or (album='')) Then Falbum := UTF8Encode(albumv2);
|
||||||
|
end else Falbum := albumv2;
|
||||||
|
if Length(Trim(Fcomment)) <> 0 then begin
|
||||||
|
If ((commentv2<>'')) And (CactusConfig.id3v2_prio Or (comment='')) Then Fcomment := UTF8Encode(commentv2);
|
||||||
|
end else Fcomment := commentv2;
|
||||||
|
{$ENDIF}
|
||||||
If ((yearv2<>'')) And (CactusConfig.id3v2_prio Or (year='')) Then Fyear := yearv2;
|
If ((yearv2<>'')) And (CactusConfig.id3v2_prio Or (year='')) Then Fyear := yearv2;
|
||||||
If ((trackv2<>'')) And (CactusConfig.id3v2_prio Or (track='')) Then ftrack := trackv2;
|
If ((trackv2<>'')) And (CactusConfig.id3v2_prio Or (track='')) Then ftrack := trackv2;
|
||||||
fileclose(mp3filehandle);
|
fileclose(mp3filehandle);
|
||||||
|
Reference in New Issue
Block a user