AudioPlayerDelegate
@protocol AudioPlayerDelegate <NSObject>
The AudioPlayerDelegate provides event callbacks for the AudioPlayer. AudioPlayerDelegate provides a small set of delegate methods in favor of notifications to allow multiple receivers of the AudioPlayer event callbacks since only one player is typically used in an application. Specifically, these methods are provided for high frequency callbacks that wrap the AudioPlayer’s internal EZAudioFile and EZOutput instances. - warning: These callbacks don’t necessarily occur on the main thread so make sure you wrap any UI code in a GCD block like: dispatch_async(dispatch_get_main_queue(), ^{ // Update UI });
-
Triggered by the AudioPlayer’s internal EZAudioFile’s EZAudioFileDelegate callback and notifies the delegate of the read audio data as a float array instead of a buffer list. Common use case of this would be to visualize the float data using an audio plot or audio data dependent OpenGL sketch. - parameter: audioPlayer The instance of the AudioPlayer that triggered the event - parameter: buffer A float array of float arrays holding the audio data. buffer[0] would be the left channel’s float array while buffer[1] would be the right channel’s float array in a stereo file. - parameter: bufferSize The length of the buffers float arrays - parameter: numberOfChannels The number of channels. 2 for stereo, 1 for mono. - parameter: audioFile The instance of the EZAudioFile that the event was triggered from
Declaration
Objective-C
- (void)audioPlayer:(AudioPlayer *)audioPlayer playedAudio:(float **)buffer withBufferSize:(UInt32)bufferSize withNumberOfChannels:(UInt32)numberOfChannels inAudioFile:(EZAudioFile *)audioFile;Swift
optional func audioPlayer(_ audioPlayer: AudioPlayer!, playedAudio buffer: UnsafeMutablePointerParameters
audioPlayerThe instance of the AudioPlayer that triggered the event
bufferA float array of float arrays holding the audio data. buffer[0] would be the left channel’s float array while buffer[1] would be the right channel’s float array in a stereo file.
bufferSizeThe length of the buffers float arrays
numberOfChannelsThe number of channels. 2 for stereo, 1 for mono.
audioFileThe instance of the EZAudioFile that the event was triggered from
-
Triggered by AudioPlayer’s internal EZAudioFile’s EZAudioFileDelegate callback and notifies the delegate of the current playback position. The framePosition provides the current frame position and can be calculated against the AudioPlayer’s total frames using the
totalFramesfunction from the AudioPlayer. - parameter: audioPlayer The instance of the AudioPlayer that triggered the event - parameter: framePosition The new frame index as a 64-bit signed integer - parameter: audioFile The instance of the EZAudioFile that the event was triggered fromDeclaration
Objective-C
- (void)audioPlayer:(AudioPlayer *)audioPlayer updatedPosition:(SInt64)framePosition inAudioFile:(EZAudioFile *)audioFile;Swift
optional func audioPlayer(_ audioPlayer: AudioPlayer!, updatedPosition framePosition: Int64, in audioFile: EZAudioFile!)Parameters
audioPlayerThe instance of the AudioPlayer that triggered the event
framePositionThe new frame index as a 64-bit signed integer
audioFileThe instance of the EZAudioFile that the event was triggered from
-
Triggered by AudioPlayer’s internal EZAudioFile’s EZAudioFileDelegate callback and notifies the delegate that the end of the file has been reached. - parameter: audioPlayer The instance of the AudioPlayer that triggered the event - parameter: audioFile The instance of the EZAudioFile that the event was triggered from
Declaration
Objective-C
- (void)audioPlayer:(AudioPlayer *)audioPlayer reachedEndOfAudioFile:(EZAudioFile *)audioFile;Swift
optional func audioPlayer(_ audioPlayer: AudioPlayer!, reachedEndOf audioFile: EZAudioFile!)Parameters
audioPlayerThe instance of the AudioPlayer that triggered the event
audioFileThe instance of the EZAudioFile that the event was triggered from
View on GitHub
AudioPlayerDelegate Protocol Reference