---
title: "AudioOutput (_AudioOutput class)"
canonical: "https://docs.cuesystem.com/space/CVCHELP/510591189/AudioOutput%20(_AudioOutput%20class)"
format: markdown
---
> Macro (toc)

---

# GetPrimaryAudioOutput

This function returns an address of a primary audio output.

Note: GetPrimaryAudioOutput function is not a member of an _AudioOutput class.

#### Syntax

```visualbasic
Function GetPrimaryAudioOutput() As AddressOf _AudioOutput
```

**Return value**

<u>[AddressOf](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/522682857/Other+operators#AddressOf)</u> <u>[_AudioOutput](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/498533122/Terminology#EmbeddedClasses)</u> as the address of the primary audio output.

# GetVolume

The function returns the value of the current volume.

#### Syntax

```visualbasic
Function GetVolume() As Long
```

#### Return value

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> as the volume value ranging from 0 to 100.

# MuteOff

The function switches on the audio output. It is the opposite of the MuteOn function.

#### Syntax

```visualbasic
Function MuteOff()
```

# MuteOn

The function mutes the audio output. However, playback doesn't stop. It is the opposite of the MuteOff function.

#### Syntax

```visualbasic
Function MuteOn()
```

# Play

The function starts playing a given sound. It returns an ID, which can be used as a parameter for the Stop function to stop the playback. The ID is a positive integral number. Sounds can be mixed, which means the Play function can be called repeatedly with different sounds. This function can play sound from sound resources in the CVC project. If you need to play sound from a file or stream, please use the command PlayStream.


> ⚠️ The command is not implemented in the appCUE for Android and appCUE for iOS apps.


#### Syntax

```visualbasic
Function Play( 
  sound As _Sound, 
  Optional flags As Long := 0, 
  Optional gain As Long := 0) 
As Long
```

#### Parameters

sound

<u>[_Sound](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/498533122/Terminology#EmbeddedClasses)</u> as the name of the sound stored in resource data.

flags

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> Optional, defaults to 0. They are the play flags. Predefined constants for flags are as follows:

|  |  |  |
| --- | --- | --- |
| Name | Value | Description |
| _PLAY_REPEAT | &H80000000 | Repeat play |
| _PLAY_WAITFORFINISH | &H40000000 | Waiting for the end of playing,. Otherwise the playintois added in thethe  queue and XPL program continues next command. |

gain

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> Optional, defaults to 0. It is the amplification in dB.

#### Return value

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> as the id number of a sound or 0 if an error occurs.

#### Example

```
GetPrimaryAudioOutput().Play(MyCommon.sndTigerRoaring)
```

# PlayStream

The function starts playing the sound from the audio stream. It returns the ID, which can be used as parameter of Stop function to stop the playback. The command returns 0 if an error occurs.  

> ℹ️ This command is not supported in the simulation in the Cue Visual Composer and always returns False.


> ℹ️ Supported Audio codecs are listed in table [https://cue.atlassian.net/wiki/spaces/CVCGC/pages/491062854](https://cue.atlassian.net/wiki/spaces/CVCGC/pages/491062854)  in the part Audio Codecs


#### Syntax

```visualbasic
Function PlayStream(audioURL As Text) As Long
```

#### Parameters

audioURL

<u>[Text](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> as the URL of the audio stream.

#### Return value

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> as the id number of an audio stream or 0 if an error occurs. A function GetLastError returns the error number.

#### Examples

```visualbasic
GetPrimaryAudioOutput().PlayStream("/filestorage/song1.mp3")
```

```visualbasic
GetPrimaryAudioOutput().PlayStream("/filestorage/rec1.wav")
```

```visualbasic
GetPrimaryAudioOutput().PlayStream("http://mymusicserver/song1.mp3")
```

# SetVolume

The function sets the volume level of audio output. Volume is set logarithmically to match the listening volume level.

#### Syntax

```visualbasic
Function SetVolume(volume As Long)
```

#### Parameters

volume

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> as the volume value ranging from 0 to 100.

# Stop

The function stops audio playback identified by soundid which is returned by Play function. If soundid is 0 then all playing sounds are stopped.

#### Syntax

```visualbasic
Function Stop(Optional soundid As Long := 0)
```

#### Parameters

soundid

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> Optional, defaults to 0. It is the id number of a sound.