unit Player_V0_2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, Menus, playlist_s0n_Klasse, player_s0n_Klasse,
ExtCtrls ;
type
TForm1 =
class(TForm)
Button_Play: TButton;
Button_previous: TButton;
Button_stop: TButton;
Button_next: TButton;
MainMenu1: TMainMenu;
N1: TMenuItem;
Open: TMenuItem;
Open_Folder: TMenuItem;
Save_Playlist: TMenuItem;
Process: TMenuItem;
Stop1: TMenuItem;
Previous: TMenuItem;
Next: TMenuItem;
View1: TMenuItem;
Playlist: TMenuItem;
FileOpenDialog: TOpenDialog;
Timer_Ablauf: TTimer;
Namefield: TPanel;
Timefield: TPanel;
CpuField: TPanel;
ScrollBar_Volume: TScrollBar;
Label_Volume: TLabel;
Id3TagInfo1: TMenuItem;
ScrollBar_Position: TScrollBar;
N2: TMenuItem;
Info1: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure OpenClick(Sender: TObject);
procedure Timer_AblaufTimer(Sender: TObject);
procedure ScrollBar_VolumeChange(Sender: TObject);
procedure ScrollBar_PositionScroll(Sender: TObject;
ScrollCode: TScrollCode;
var ScrollPos: Integer);
procedure PlaylistClick(Sender: TObject);
procedure Button_nextClick(Sender: TObject);
procedure Button_previousClick(Sender: TObject);
procedure Info1Click(Sender: TObject);
procedure Button_PlayClick(Sender: TObject);
procedure Button_stopClick(Sender: TObject);
procedure FormClick(Sender: TObject);
private
{ Private-Deklarationen }
public
end;
var
Form1: TForm1;
sPlayer: Ts0nPlayer;
posScroll: longword;
ScrollMAx: integer;
Const
BASS_ACTIVE_STOPPED = 0;
BASS_ACTIVE_PLAYING = 1;
BASS_ACTIVE_STALLED = 2;
BASS_ACTIVE_PAUSED = 3;
implementation
uses window_playlist;
{$R *.dfm}
//*************************************************************
//Beim Starten des Hauptfensters wird diese Procedur ausgeführt
//*************************************************************
procedure TForm1.FormCreate(Sender: TObject);
var tempL: real;
begin
// Objekte erstellen
sPlayer := ts0nplayer.Create;
// Bass Engine initialisieren
sPlayer.BassEngineInit(
handle);
// Anfangs Lautstärke auf 30 % setzen
tempL:=30;
sPlayer.Lauststaerke(tempL);
// ScrollBar für Volume setzen
scrollbar_Volume.Position := Round(tempL);
end;
//*************************************************************
// Action nach Open Klick
//*************************************************************
procedure TForm1.OpenClick(Sender: TObject);
var sadded:
string;
i : integer;
begin
// Eigenschaften des Open Dialog setzen
FileOpenDialog.Title:='
Open Files ...';
FileOpenDialog.Filter:='
MP3 Dateien|*.mp3|Wave Dateien|*.wav';
if FileOpenDialog.Execute
then
for i := 0
to FileOpenDialog.Files.Count - 1
do
begin
sAdded:= FileOpenDialog.Files[i] ;
// sPlaylist.AddTrack(sAdded);
playlist_s0n_Klasse.Playlist.AddTrack(sadded);
end;
end;
//*************************************************************
// Tímer
//*************************************************************
procedure TForm1.Timer_AblaufTimer(Sender: TObject);
var temp: integer;
temp2:
string;
begin
Timer_Ablauf.Interval:=100;
CpuField.Caption:= '
CPU: ' + sPlayer.GetCpuStatus + '
%';
// Wenn die interne Playlist keine Traxx enthält dann werden die Buttons gesperrt
if playlist_s0n_Klasse.Playlist.Getcount > 0
then
begin
Button_Play.Enabled := true;
Button_previous.Enabled := true;
Button_Next.Enabled := true;
Button_Stop.Enabled := true;
end else
begin
Button_Play.Enabled := false;
Button_previous.Enabled := false;
Button_Next.Enabled := false;
Button_Stop.Enabled := false;
end;
// Wenn Wiedergabe gestartet wird der Position Regler freigegeben und die Zeiten aktualisiert
if splayer.GetBassStatus = BASS_ACTIVE_PLAYING
then
begin
ScrollBar_Position.Enabled := true ;
temp:= Round( sPlayer.GetTrackTimeRunSec / sPlayer.GetTrackTimeLoadSec * 1000);
if ScrollBar_Position.Tag = 0
then
ScrollBar_Position.Position:= temp;
Namefield.Caption:=extractfilename(playlist_s0n_Klasse.Playlist.ActTrackName);
TimeField.Caption:= sPlayer.GetActualTime + '
/' + splayer.GetTrackTimeRun;
end;
if Scrollbar_Position.Position = 1000
then
begin
temp2:= playlist_s0n_Klasse.Playlist.GetNextTrackName;
sPlayer.Abspielen(temp2);
end;
end;
//*************************************************************
// Volume Scroller
//*************************************************************
procedure TForm1.ScrollBar_VolumeChange(Sender: TObject);
var tempScroll: real;
begin
tempScroll:=ScrollBar_Volume.Position / 100;
sPlayer.Lauststaerke(tempScroll);
Label_Volume.Caption:=(FloatToStr(tempScroll*100)) + '
%';
end;
//Button Play
procedure TForm1.Button_PlayClick(Sender: TObject);
begin
playlist_s0n_Klasse.Playlist.PlayActTrack;
end;
//Button Next Track
procedure TForm1.Button_nextClick(Sender: TObject);
begin
playlist_s0n_Klasse.Playlist.PlayNextTrack;
end;
//Button Previous Track
procedure TForm1.Button_previousClick(Sender: TObject);
begin
playlist_s0n_Klasse.Playlist.PlayPreviousTrack;
end;
//Button Stop
procedure TForm1.Button_stopClick(Sender: TObject);
begin
playlist_s0n_Klasse.Playlist.StopActTrack;
ScrollBar_Position.Position:=0;
end;
//ScrollBar Action nach beenden des Scrollens
procedure TForm1.ScrollBar_PositionScroll(Sender: TObject;
ScrollCode: TScrollCode;
var ScrollPos: Integer);
begin
if Scrollcode = scEndScroll
then
begin
ScrollMax:=ScrollBar_Position.Max;
posScroll:= ScrollBar_Position.Position;
sPlayer.SetPosition(posScroll,ScrollMax);
ScrollBar_Position.Tag:=0;
end else
ScrollBar_Position.Tag:=1;
end;
// Menu Einträge die angelkickt werden
//Menu View - Show - Anzeigen des Playlist Fensters
procedure TForm1.PlaylistClick(Sender: TObject);
begin
Form2.Show;
end;
// Menu ? - Info
procedure TForm1.Info1Click(Sender: TObject);
begin
ShowMessage('
programmed by s0n: Version 0.2');
end;
procedure TForm1.FormClick(Sender: TObject);
begin
showMessage(inttostr(playlist_s0n_Klasse.Playlist.Getcount));
end;
end.