/
se.game.script.package.sound.pas
96 lines (82 loc) · 2.54 KB
/
se.game.script.package.sound.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
{******************************************************************************}
{ }
{ SE Network Development Framework }
{ }
{ Copyright (c) 2018 looper(2031056602@qq.com) }
{ }
{ Source: https://github.com/looper/se-framework }
{ Homepage: http://www.asphyre.cn }
{ }
{******************************************************************************}
unit se.game.script.package.sound;
interface
uses
System.Classes, System.SysUtils, System.IOUtils, FMX.Forms, FMX.Controls,
VerySimple.Lua, VerySimple.Lua.Lib,
se.game.types, se.game.script.package, se.game.sound, se.game.sound.bass;
type
TSoundPackage = class(TScriptPackage)
private
FSoundPlayer: TSoundPlayer;
public
constructor Create; override;
destructor Destroy; override;
procedure RegFunctions; override;
published
/// <summary>
/// ²¥·Å
/// </summary>
function play(L: lua_State): Integer;
/// <summary>
/// ÔÝÍ£
/// </summary>
function pause(L: lua_State): Integer;
/// <summary>
/// ֹͣ
/// </summary>
function stop(L: lua_State): Integer;
end;
implementation
{ TSoundPackage }
constructor TSoundPackage.Create;
begin
inherited;
FSoundPlayer:= TBassSoundPlayer.Create(TPath.GetTempPath);
end;
destructor TSoundPackage.Destroy;
begin
FreeAndNil(FSoundPlayer);
inherited;
end;
procedure TSoundPackage.RegFunctions;
begin
inherited;
RegFunction('play','play');
RegFunction('pause','pause');
RegFunction('stop','stop');
end;
function TSoundPackage.play(L: lua_State): Integer;
var
LSoundFileName: string;
begin
LSoundFileName:= lua_tostring(L, 2);
//test
Self.InvokeLuaMethod('OutputDebugString', 'play: ' + LSoundFileName);
end;
function TSoundPackage.pause(L: lua_State): Integer;
var
LSoundFileName: string;
begin
LSoundFileName:= lua_tostring(L, 2);
//test
Self.InvokeLuaMethod('OutputDebugString', 'pause: ' + LSoundFileName);
end;
function TSoundPackage.stop(L: lua_State): Integer;
var
LSoundFileName: string;
begin
LSoundFileName:= lua_tostring(L, 2);
//test
Self.InvokeLuaMethod('OutputDebugString', 'stop: ' + LSoundFileName);
end;
end.