www.pudn.com > DirectShowPlayer.rar > Common.pas
// Avalon Media Player
// Copyright © 2001 Pulsar Studio / Lord Trancos.
unit common;
// -------------------------------------------------------------------
interface
uses Windows, Messages, Classes, ExtCtrls, Skinned,
SysUtils, ShlObj, DX8DS;
const
WINDOWCLASSNAME = 'Avalon Media Player Main Window';
TITLE = 'Avalon Media Player (beta 1b)';
ABOUT = TITLE+#10+'Copyright © 2001 Pulsar Studio / Lord Trancos.'+#10+
#10+'Avalon Media Player (AMP) is a freeware product,'+
#10+'as such you can not expect any warranty of usability'+
#10+'nor stability.'+#10+
#10+'Use of this program (and/or its source code) commercially'+
#10+'without prior consent of the author is prohibited,'+
#10+'violators will be prosecuted to the full extent of the law.'+#10+
#10+'Special thanks to Ampaze for his bug fix.';
MSG00 = 'Subdirectories';
MSG01 = 'Do you want to add subdirectories?';
REG_KEY00 = 'Software\Pulsar Studio\AvalonMP\(alpha)';
EXT_AMP = '.amp';
EXT_FILTER = '.wav;.mpa;.mp2;.mp3;.au;.aif;.aiff;.snd;.avi;.qt;'+
'.mov;.mpg;.mpeg;.m1v;.asf;.wma;.wmv;.mid;.midi;.rmi;';
EXT_DELIMITER = ';';
STATE_STOP = 0;
STATE_PLAY = 1;
STATE_PAUSE = 2;
// Custom Messages.
CM_OPENFILE = WM_USER + $1000;
var
Player : TDSMP;
PlayState : longint = STATE_STOP;
CurrentFile : string = '';
CurrentIdx : longint = -1;
OSDInfoTxt : string = '';
Duration : int64;
CurrPos : int64;
DurationStr : string = '';
function ChooseDir(_owner: hWnd; _title: pChar): string;
procedure AddDirToList(_dir: string; _dest: TStrings;
_subDirs: boolean);
procedure skinImgSetCellAndUpdate(_img: TImage; _cell: byte);
function skinImgInitAndUpdate(_img: TImage; _srcPoint: TPoint): boolean;
procedure skinChecked(var _img: TImage; _checked : boolean);
// -------------------------------------------------------------------
implementation
// -------------------------------------------------------------------
function ChooseDir(_owner: hWnd; _title: pChar): string;
var _browInfo : TBrowseInfo;
_PIDL : PItemIDList;
_name : array[0..MAX_PATH] of char;
begin
Result := '';
FillChar(_browInfo, sizeOf(_browInfo), 0);
with _browInfo do
begin
hwndOwner := _owner;
pszDisplayName := @_name[0];
lpszTitle := _title;
ulFlags := BIF_RETURNONLYFSDIRS;
end;
_PIDL := SHBrowseForFolder(_browInfo);
if Assigned(_PIDL) then
if SHGetPathFromIDList(_PIDL, _name)
then Result := StrPas(_name);
end;
// -------------------------------------------------------------------
function ExtMatch(_fileext, _exts: string; _delimiter: char): boolean;
var _pos : longint;
begin
Result := false;
// Check strings.
if (length(_fileext) = 0) or (length(_exts) = 0) then exit;
// Rewrite strings.
_fileext := _delimiter + UpperCase(_fileext) + _delimiter;
_exts := _delimiter + UpperCase(_exts) + _delimiter;
// Search.
_pos := Pos(_fileext, _exts);
// Found ?
Result := (_pos <> 0);
end;
// -------------------------------------------------------------------
procedure AddDirToList(_dir: string; _dest: TStrings;
_subDirs: boolean);
var _sr : TSearchRec;
_l : longint;
_i : integer;
begin
_l := length(_dir);
if (_l = 0) then exit;
// rewrite path
if (_dir[_l] <> ':') and (_dir[_l] <> '\') then _dir := _dir + '\';
// Add files.
_i := FindFirst(_dir + '*.*', $37, _sr);
while (_i = 0) do
begin
// it's a directory ?
if (_sr.Attr and $10 = $10) and (_sr.name <> '.') and
(_sr.name <> '..') and (_subdirs)
then AddDirToList(_dir + _sr.name, _dest, _subdirs) else
if ExtMatch(ExtractFileExt(_sr.name), EXT_FILTER, EXT_DELIMITER) then
if _dest.IndexOf(_dir + _sr.name) = -1
then _dest.Add(_dir + _sr.name);
_i := FindNext(_sr);
end;
FindClose(_sr);
end;
// -------------------------------------------------------------------
procedure skinImgSetCellAndUpdate(_img: TImage; _cell: byte);
begin
skinImgSetCell(_img, _cell);
skinImgUpdate(_img);
end;
// --------------------------------------------------------------------
function skinImgInitAndUpdate(_img: TImage; _srcPoint: TPoint): boolean;
begin
Result := skinInitImg(_img, _srcPoint);
if (Result) then skinImgUpdate(_img);
end;
// --------------------------------------------------------------------
procedure skinChecked(var _img: TImage; _checked : boolean);
begin
if _checked then
begin
skinImgSetValue(_img, SKIN_CHKVAL_TRUE);
skinImgSetCellAndUpdate(_img, 2);
end else begin
skinImgSetValue(_img, SKIN_CHKVAL_FALSE);
skinImgSetCellAndUpdate(_img, 0);
end;
end;
// --------------------------------------------------------------------
end.