Skip to content

回放控制 - InputPlayback

函数简介

按录制 JSONL 中的相对时间 t_ms 回放键鼠。典型流程:LOADSTART →(可选 PAUSE / SEEK / STOP)→ FREE

需要 InputSync 权限。路径相对 WorkPath;非 LOAD 动作 path 传 ""

接口名称

InputPlayback

DLL调用

c
long InputPlayback(long instance, long handle, int action, string path, double speed, long seek_ms, int flags);

参数说明

参数名类型说明
instance长整数型OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。在该实例上执行回放。
handle长整数型回放句柄;LOAD 时可传 0。
action整数型见下表。
path字符串LOAD 时的 JSONL 路径;其它动作传 ""
speed双精度START 播放倍率,<=0 视为 1.0。
seek_ms长整数型SEEK 目标相对时间(毫秒)。
flags整数型START 时可选标志位或。

action

常量说明
1LOAD加载文件,返回 handle(>0
2START开始播放
3PAUSE暂停
4STOP停止本次播放(句柄仍可用)
5SEEK跳转
6FREE释放句柄(必须)

START flags

含义
0x1MONITOR:回放事件也进 InputMonitor
0x2BROADCAST:再广播给已绑定从实例
0x4LOOP:播完从起点循环,直到 STOP/FREE

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
long long h = ola.InputPlayback(0, 1, "input_rec/demo.jsonl", 0, 0, 0);
ola.InputPlayback(h, 2, "", 1.0, 0, 4);  // START + LOOP
// ...
ola.InputPlayback(h, 4, "", 0, 0, 0);    // STOP
ola.InputPlayback(h, 6, "", 0, 0, 0);    // FREE
csharp
using OLAPlug;

var ola = new OLAPlugServer();
long h = ola.InputPlayback(0, 1, "input_rec/demo.jsonl", 0, 0, 0);
ola.InputPlayback(h, 2, "", 1.0, 0, 4);
ola.InputPlayback(h, 4, "", 0, 0, 0);
ola.InputPlayback(h, 6, "", 0, 0, 0);
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
h = ola.InputPlayback(0, 1, "input_rec/demo.jsonl", 0, 0, 0)
ola.InputPlayback(h, 2, "", 1.0, 0, 4)
ola.InputPlayback(h, 4, "", 0, 0, 0)
ola.InputPlayback(h, 6, "", 0, 0, 0)
java
import com.olaplug.OLAPlugServer;

OLAPlugServer ola = new OLAPlugServer();
long h = ola.InputPlayback(0, 1, "input_rec/demo.jsonl", 0, 0, 0);
ola.InputPlayback(h, 2, "", 1.0, 0, 4);
ola.InputPlayback(h, 4, "", 0, 0, 0);
ola.InputPlayback(h, 6, "", 0, 0, 0);
go
import "github.com/ola/olaplug/olaplug"

ola, _ := olaplug.NewOLAPlugServer("OLAPlug_x64.dll")
defer ola.ReleaseObj()
h := ola.InputPlayback(0, 1, "input_rec/demo.jsonl", 0, 0, 0)
ola.InputPlayback(h, 2, "", 1.0, 0, 4)
ola.InputPlayback(h, 4, "", 0, 0, 0)
ola.InputPlayback(h, 6, "", 0, 0, 0)
rust
use olaplug::OLAPlugServer;

let ola = OLAPlugServer::new("OLAPlug_x64.dll").unwrap();
let h = ola.input_playback(0, 1, "input_rec/demo.jsonl", 0.0, 0, 0);
ola.input_playback(h, 2, "", 1.0, 0, 4);
ola.input_playback(h, 4, "", 0.0, 0, 0);
ola.input_playback(h, 6, "", 0.0, 0, 0);
cpp
var ola = com("OlaPlug.OlaSoft")
var h = ola.InputPlayback(0, 1, "input_rec/demo.jsonl", 0, 0, 0)
ola.InputPlayback(h, 2, "", 1.0, 0, 4);
ola.InputPlayback(h, 4, "", 0, 0, 0);
ola.InputPlayback(h, 6, "", 0, 0, 0);
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
h = ola.InputPlayback(0, 1, "input_rec/demo.jsonl", 0, 0, 0)
ola.InputPlayback(h, 2, "", 1.0, 0, 4)
ola.InputPlayback(h, 4, "", 0, 0, 0)
ola.InputPlayback(h, 6, "", 0, 0, 0)
text
.局部变量 ola, OLAPlug
ola.创建 ()
h = ola.InputPlayback(0, 1, "input_rec/demo.jsonl", 0, 0, 0)
ola.InputPlayback(h, 2, "", 1.0, 0, 4)
ola.InputPlayback(h, 4, "", 0, 0, 0)
ola.InputPlayback(h, 6, "", 0, 0, 0)
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var h = ola.InputPlayback(0, 1, "input_rec/demo.jsonl", 0, 0, 0);
ola.InputPlayback(h, 2, "", 1.0, 0, 4);
ola.InputPlayback(h, 4, "", 0, 0, 0);
ola.InputPlayback(h, 6, "", 0, 0, 0);
text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
长整数 h = ola.InputPlayback(0, 1, "input_rec/demo.jsonl", 0, 0, 0)
ola.InputPlayback(h, 2, "", 1.0, 0, 4);
ola.InputPlayback(h, 4, "", 0, 0, 0);
ola.InputPlayback(h, 6, "", 0, 0, 0);
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
int64_t h = ola.InputPlayback(0, 1, "input_rec/demo.jsonl", 0, 0, 0);
ola.InputPlayback(h, 2, "", 1.0, 0, 4);
ola.InputPlayback(h, 4, "", 0, 0, 0);
ola.InputPlayback(h, 6, "", 0, 0, 0);

原生 DLL 调用

cpp
long instance = CreateCOLAPlugInterFace();
long h = InputPlayback(instance, 0, 1, "input_rec/demo.jsonl", 0, 0, 0);
InputPlayback(instance, h, 2, "", 1.0, 0, 4);
InputPlayback(instance, h, 4, "", 0, 0, 0);
InputPlayback(instance, h, 6, "", 0, 0, 0);
csharp
using System.Runtime.InteropServices;

[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long InputPlayback(long instance, long handle, int action, string path, double speed, long seek_ms, int flags);

long instance = CreateCOLAPlugInterFace();
long h = InputPlayback(instance, 0, 1, "input_rec/demo.jsonl", 0, 0, 0);
InputPlayback(instance, h, 2, "", 1.0, 0, 4);
InputPlayback(instance, h, 4, "", 0, 0, 0);
InputPlayback(instance, h, 6, "", 0, 0, 0);
python
from ctypes import CDLL, c_int64, c_double

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
ola.InputPlayback.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
h = ola.InputPlayback(instance, 0, 1, b"input_rec/demo.jsonl", c_double(0), 0, 0)
ola.InputPlayback(instance, h, 2, b"", c_double(1.0), 0, 4)
ola.InputPlayback(instance, h, 4, b"", c_double(0), 0, 0)
ola.InputPlayback(instance, h, 6, b"", c_double(0), 0, 0)

返回值

返回值说明
>0LOAD 成功,返回回放句柄。
1其它动作成功。
0 或负值失败。

相关接口