ReframeworkAudio

ReframeworkAudio

provides global methods for Reframework's Lua to play audio you want 为ref的lua脚本注册全局函数以实现音频播放

描述

为 ref 的 lua 脚本提供全局函数以实现自主播放音频

安装方法

  1. 下载 ReframeworkAudio.dll
  2. 放入游戏目录下的 reframework\plugins\ 文件夹
  3. 启动游戏,REFramework 会自动加载插件
  4. 验证:查看游戏目录下 re2_framework_log.txt,出现以下日志即成功: [ReframeworkAudio] ReframeworkAudio 插件初始化完成 [ReframeworkAudio] Lua 音频函数注册完成

使用方式

所有函数注册为 Lua 全局函数,直接调用即可(无需 require)。

函数                      返回值    说明
loadAudio (name, path)     bool     加载音频,支持 WAV / OGG / MP3
playAudio (name)           bool     播放(会停止当前正在播放的音频)
pauseAudio (name)          bool     暂停(仅对当前播放项有效)
resumeAudio (name)         bool     恢复播放
seekAudio (name, position) bool     跳转,position 单位为 秒
setVolume (name, volume)   bool     音量,范围 0‑128
getCurrentPosition (name)  double   当前播放进度(秒),未播放返回 0.0
getAudioSize (name)        double   音频总时长(秒)
deleteAudio (name)         nil      释放音频资源

前置

需要 Reframework

鸣谢

参考了 HalcyonAlcedo 大佬的 LuaEngineAudio,感谢尊尊模组的启发


Description

Provide global functions for REFramework Lua scripts to enable native audio playback.

Installation instructions

  1. Download ReframeworkAudio.dll
  2. Place it into the reframework\plugins\ folder under your game directory
  3. Launch the game; REFramework will automatically load the plugin
  4. Verification: Check re2_framework_log.txt in the game directory. The following log entries indicate successful initialization: [ReframeworkAudio] ReframeworkAudio plugin initialization complete [ReframeworkAudio] Lua audio functions registered successfully

Usage

All functions are registered as Lua global functions. Call them directly (no require required).

Function                  Return    Description
loadAudio (name, path)    bool      Load audio, supports WAV / OGG / MP3
playAudio (name)          bool      Play (stops currently playing audio)
pauseAudio (name)         bool      Pause (only valid for active playback)
resumeAudio (name)        bool      Resume playback
seekAudio (name, position) bool     Seek, position unit: seconds
setVolume (name, volume)  bool      Set volume, range 0‑128
getCurrentPosition (name) double    Current playback position in seconds, returns 0.0 if not playing
getAudioSize (name)       double    Total audio duration in seconds
deleteAudio (name)        nil       Release audio resource

Requirements

Requires REFramework