Implements Module Player working in Form
* Implements Embedding .xm music in Final Application
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
unit main;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
{$R music.res}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,
|
||||
ComCtrls, ExtendedTabControls, fphttpclient, opensslsockets, fpjson,
|
||||
jsonparser, ThreadUnit;
|
||||
jsonparser, ThreadUnit, uos, uos_portaudio, uos_flat, uos_libxmp, Windows;
|
||||
|
||||
type
|
||||
|
||||
@@ -41,17 +42,40 @@ var
|
||||
jData: TJSONData;
|
||||
packageData: TJSONObject;
|
||||
test1: ThreadClass;
|
||||
ResStream: TResourceStream;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
{ TForm1 }
|
||||
function ExtractResourceToTempFile(const ResName: string): string;
|
||||
var
|
||||
ResStream: TResourceStream;
|
||||
TempPath, TempFileName: string;
|
||||
begin
|
||||
TempPath := GetTempDir;
|
||||
TempFileName := TempPath + '5f64126c-1f61-4e65-8250-4a7835d2f155';
|
||||
|
||||
ResStream := TResourceStream.Create(HInstance, ResName, RT_RCDATA);
|
||||
try
|
||||
ResStream.SaveToFile(TempFileName);
|
||||
finally
|
||||
ResStream.Free;
|
||||
end;
|
||||
|
||||
Result := TempFileName;
|
||||
end;
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
begin
|
||||
BtnSearch.Enabled := False;
|
||||
//loonie_mifue.xm
|
||||
|
||||
uos_LoadLib( pchar('LibPortaudio-64.dll'), nil, nil, nil, nil, nil, pchar('libxmp-64.dll'));
|
||||
uos_CreatePlayer( 0 );
|
||||
uos_AddIntoDevOut( 0 );
|
||||
uos_AddFromFile( 0, PChar(ExtractResourceToTempFile('LOONIEMUSIC')));
|
||||
uos_Play(0);
|
||||
end;
|
||||
|
||||
procedure TForm1.BtnSearchClick(Sender: TObject);
|
||||
@@ -63,6 +87,7 @@ begin
|
||||
Response := Client.Get(Concat('https://registry.npmjs.org/', PackageName));
|
||||
jData := GetJSON(Response);
|
||||
packageData := jData as TJSONObject;
|
||||
|
||||
memoTest.Lines.Text := jData.FormatJSON;
|
||||
finally
|
||||
Client.Free;
|
||||
@@ -81,5 +106,5 @@ begin
|
||||
else
|
||||
BtnSearch.Enabled := False;
|
||||
end;
|
||||
|
||||
end.
|
||||
uos_free;
|
||||
|
||||
Reference in New Issue
Block a user