Rate this page:

VIAudioFile

File player that automatically prepares audio session and plays sounds.

Supported file formats are: .caf, .wav, .aiff, .aifc, .mp3, .ac3

Limitations:

  • Playing audio file is not supported while there is an active connected call.
  • Playing audio file may be interrupted if audio within a call is started.
  • Playing audio file stops if Siri or CallKit is activated.

Props

delegate

Copy URL
var delegate: 

id<VIAudioFileDelegate>

Delegate that handles events related to audio file playing process.

Returns

delegateQueue

Copy URL
var delegateQueue: 

dispatch_queue_t

All delegates methods are called on this queue. The queue should be serial, but not concurrent (the main queue is applicable).

If not specified, the main queue is used.

Returns

  • type:

    dispatch_queue_t

looped

Copy URL
var looped: 

BOOL

Whether to play audio file repeatedly in loop or once.

Returns

  • type:

    BOOL

url

Copy URL
val url: 

NSURL *

Audio file's URL.

Returns

  • type:

    NSURL *

Methods

initWithData:looped:

Copy URL
fun initWithData:looped:(audioFileData: 

NSData *

,
looped:

BOOL

):

nullable instancetype

Initializes the audio file instance.

Parameters

  • audioFileData:

    NSData *

    Audio file Data

  • looped:

    BOOL

    Whether to play audio file repeatedly in loop or once

Returns

  • type:

    nullable instancetype

initWithURL:looped:

Copy URL
fun initWithURL:looped:(audioFileURL: 

NSURL *

,
looped:

BOOL

):

nullable instancetype

Initializes the audio file instance.

Parameters

  • audioFileURL:

    NSURL *

    Audio file URL

  • looped:

    BOOL

    Whether to play audio file repeatedly in loop or once

Returns

  • type:

    nullable instancetype

play

Copy URL
fun play(): 

void

Starts playing the audio file repeatedly or once based on [VIAudioFile looped] property.

If the audio file is already playing, calling this method results in [VIAudioFileDelegate audioFile:didStartPlaying:] event with an error.

Returns

  • type:

    void

stop

Copy URL
fun stop(): 

void

Stops playing the audio file.

Calling this method has no effect if the audio file is not playing.

Returns

  • type:

    void