- resources: 更新 asyncloader, audioclip, mesh-import-settings, texture-loader 文档 - rhi: 更新 opengl render-target-view 文档 - components: 新增 camera-component 全部方法文档 (15个文件)
42 lines
830 B
Markdown
42 lines
830 B
Markdown
# SetTime
|
|
|
|
**所属类**: `AudioSourceComponent`
|
|
|
|
**头文件**: `XCEngine/Components/AudioSourceComponent.h`
|
|
|
|
**描述**: 设置音频源的当前播放位置。
|
|
|
|
## 函数签名
|
|
|
|
```cpp
|
|
void SetTime(float seconds);
|
|
```
|
|
|
|
## 参数
|
|
|
|
| 参数 | 类型 | 描述 |
|
|
|------|------|------|
|
|
| `seconds` | `float` | 播放位置,单位秒 |
|
|
|
|
## 使用示例
|
|
|
|
```cpp
|
|
#include <XCEngine/Components/AudioSourceComponent.h>
|
|
|
|
using namespace XCEngine::Components;
|
|
|
|
void SeekToPosition(AudioSourceComponent* source, float seconds) {
|
|
source->SetTime(seconds);
|
|
}
|
|
|
|
void RewindToStart(AudioSourceComponent* source) {
|
|
source->SetTime(0.0f);
|
|
}
|
|
```
|
|
|
|
## 相关文档
|
|
|
|
- [AudioSourceComponent](audio-source-component.md) - 音频源组件
|
|
- [GetTime](get-time.md) - 获取当前播放位置
|
|
- [GetDuration](get-duration.md) - 获取总时长
|