开发者

How to stop Repeated Audio play in Audio Mixer (MixerHost) for iOS

开发者 https://www.devze.com 2023-03-14 14:36 出处:网络
I have got Audio Mixer(MixerHost) sample code from Apple iOS. This code is working fine. It is playing the sample Audio files continuously. Can you tell me how to stop my Mixer code to stop after pla

I have got Audio Mixer(MixerHost) sample code from Apple iOS. This code is working fine. It is playing the sample Audio files continuously. Can you tell me how to stop my Mixer code to stop after playing audio once?

Is it possible disable repeat开发者_运维百科ed play using AVAudiosession.


Do you have this method?

// Handle a play/stop button tap
- (IBAction) playOrStop: (id) sender


In MixerHostAudio.m, inside the inputRenderCallback method, just comment the line

if (sampleNumber >= frameTotalForSound) sampleNumber = 0;


Try to implement this inputRenderCallback as below:

if (sampleNumber >= frameTotalForSound) {
     [[NSNotificationCenter defaultCenter] postNotificationName:NOTI_AUDIO object:nil userInfo:nil];
     return noErr;
}

The NSNotification "NOTI_AUDIO" just let the viewcontroller know when the audio is stopped.

Hope this helps!

0

精彩评论

暂无评论...
验证码 换一张
取 消