VIAudioFile
VoximplantCore · iOS SDK v3
File player that plays local audio via AVAudioPlayer.
@objc final class VIAudioFile
Use this API for application sounds such as a ringtone or hold music. Supported file formats are: .caf, .wav, .aiff, .aifc, .mp3, and .ac3.
Outside a call or conference, playback configures the audio session with the .playback category. During a call or conference, playback reuses the existing .playAndRecord plus .voiceChat session.
Multiple VIAudioFile instances can play at the same time.
Initializers
init(data:)
@objc convenience init(data: Data) throws
Creates an audio file player from in-memory audio data.
Parameters
data Data
Audio file contents.
Throws
VIAudioFileError with VIAudioFileErrorType.failedToInitialize if the player cannot be created.
init(url:)
@objc convenience init(url: URL) throws
Creates an audio file player from a local file URL.
Parameters
url URL
Local file URL of the audio resource.
Throws
VIAudioFileError with VIAudioFileErrorType.failedToInitialize if the player cannot be created.
Properties
delegate
@objc weak var delegate: VIAudioFileDelegate?
Object that conforms to the VIAudioFileDelegate protocol to receive playback events.
isPlaying
@objc var isPlaying: Bool { get }
Whether the audio file is currently playing.
url
@objc var url: URL? { get }
File URL used to create this player, or nil if the player was created from data.
Methods
pause()
@objc func pause()
Pauses playback and reports audioFile(_:didStopPlaying:) with a nil error.
Has no effect if the file is not playing.
play()
@objc func play()
Starts playback once from the current position.
Reports the result via audioFile(_:didStartPlaying:). If the file is already playing, reports VIAudioFileErrorType.alreadyPlaying.
playLooped()
@objc func playLooped()
Starts looped playback from the current position.
Reports the result via audioFile(_:didStartPlaying:). If the file is already playing, reports VIAudioFileErrorType.alreadyPlaying.
stop()
@objc func stop()
Stops playback, resets the position to the beginning, and reports audioFile(_:didStopPlaying:) with a nil error.
Has no effect if the file is not playing.
Relationships
Inherits From: NSObject
Conforms To: ObjectiveC.NSObjectProtocol, Swift.CVarArg, Swift.CustomDebugStringConvertible, Swift.CustomStringConvertible, Swift.Equatable, Swift.Hashable