Hello,I have the following code to get an AVAudioSequencer playing a MIDI file: AVAudioEngine *engine;
AVAudioUnitSampler *sampler;
AVAudioSequencer *sequencer;
engine = [[AVAudioEngine alloc] init];
sampler = [[AVAudioUnitSampler alloc] init];
[engine attachNode:sampler];
[engine connect:sampler to:engine.mainMixerNode format:nil];
NSURL *url = [NSBundle.mainBundle URLForResource:@"mysamples" withExtension:@"sf2"];
[sampler loadSoundBankInstrumentAtURL:url program:0
bankMSB:(UInt8)kAUSampler_DefaultMelodicBankMSB
bankLSB:(UInt8)kAUSampler_DefaultBankLSB error:&err];
sequencer = [[AVAudioSequencer alloc] initWithAudioEngine:engine];
[engine startAndReturnError:&err];
[AVAudioSession.sharedInstance setCategory:AVAudioSessionCategoryPlayback error:&err];
[sequencer loadFromData:someMidiData options:AVMusicSequenceLoadSMF_PreserveTracks error:&err];
[sequencer startAndReturnError:&err];It is fairly straightforward code and it works.The point is that I need to be notified when the playback completes and I don't know how to achieve this.The best thing I have thought so far is polling the sequnecer's isPolling property.I know some objects can be connected to an AudioCompletionHandler, but I don't think it's the case of the sequencer, since it does not inherit from AVAudioNode.Any help is appreciated.
Post
Replies
Boosts
Views
Activity
I need to cancel some non-consumable purchases in the sandbox environment to see if my app handles the cancellation_date field properly.How do I do that?Doing it through iTunes seems to work for the production environment only, since it does not recognize the user I have created for testing in the sandbox.