> ## Documentation Index
> Fetch the complete documentation index at: https://rive.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# AudioSound

A playback instance returned by `Audio:play*`, with controls for transport and volume.

## Fields

### `volume`

volume of the sound.

```lua highlight={4} theme={null}
function update(self: AudioScript)
  -- updates the volume for AudioSound playback when the input is changed
  if self.soundInstance then
    self.soundInstance.volume = self.volumeNumber / 100
  end
end
```

## Methods

### `stop`

<div class="signature">
  ```lua theme={null}
  stop(fadeToStopTime: number?) -> ()
  ```
</div>

stop the audio

```lua highlight={3} theme={null}
function stopSound(self: AudioScript)
  if self.soundInstance then
    self.soundInstance:stop()
  end
end
```

### `seek`

<div class="signature">
  ```lua theme={null}
  seek(seconds: number) -> ()
  ```
</div>

seek the audio to a specific time in seconds.

```lua theme={null}
if self.soundInstance then
  self.soundInstance:seek(self.seekSeconds)
end
```

### `seekFrame`

<div class="signature">
  ```lua theme={null}
  seekFrame(frame: number) -> ()
  ```
</div>

seek the audio to a specific time in PCM frames.

```lua theme={null}
if self.soundInstance then
  self.soundInstance:seekFrame(self.seekFrameNumber)
end
```

### `completed`

<div class="signature">
  ```lua theme={null}
  completed() -> boolean
  ```
</div>

Whether the sound has completed playing.

```lua highlight={3} theme={null}
function advance(self: AudioScript, seconds: number): boolean
  if self.soundInstance then
    self.isCompleted = self.soundInstance:completed()      -- whether playback has finished
  end
  return true
end
```

### `time`

<div class="signature">
  ```lua theme={null}
  time() -> number
  ```
</div>

Current sound time in seconds.

```lua highlight={3} theme={null}
function advance(self: AudioScript, seconds: number): boolean
  if self.soundInstance then
    self.currentTime = self.soundInstance:time()           -- current playback time in seconds
  end
  return true
end
```

### `timeFrame`

<div class="signature">
  ```lua theme={null}
  timeFrame() -> number
  ```
</div>

Current sound time in PCM frames.

```lua highlight={3} theme={null}
function advance(self: AudioScript, seconds: number): boolean
  if self.soundInstance then
    self.currentTimeFrame = self.soundInstance:timeFrame() -- current playback time in PCM frames
  end
  return true
end
```

### `pause`

<div class="signature">
  ```lua theme={null}
  pause() -> ()
  ```
</div>

pauses the audio.

```lua highlight={3} theme={null}
function pauseSound(self: AudioScript)
  if self.soundInstance then
    self.soundInstance:pause()
  end
end
```

### `resume`

<div class="signature">
  ```lua theme={null}
  resume() -> ()
  ```
</div>

resumes the audio from its current position.

```lua highlight={3} theme={null}
function resumeSound(self: AudioScript)
  if self.soundInstance then
    self.soundInstance:resume()
  end
end
```

### `play`

<div class="signature">
  ```lua theme={null}
  play() -> ()
  ```
</div>

plays the audio.

```lua highlight={3} theme={null}
function playSound(self: AudioScript)
  if self.soundInstance then
    self.soundInstance:play()
  end
end
```
