42 lines
836 B
Markdown
42 lines
836 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) - 获取总时长
|