Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS & CoreAudio: Calling MusicPlayerSetTime() stops MusicPlayer
    primarykey
    data
    text
    <p>I'm using CoreAudio on iOS 5 to play MIDI files. I have everything setup, it works, everything's peachy, except when I want to start over the sequence from the start <strong>during the playback</strong>. To do that I naturally call:</p> <pre><code> if (MusicPlayerSetTime(musicPlayer, (MusicTimeStamp)0.0) != noErr) [NSException raise:@"playMIDI" format:@"Can't reset the player"]; </code></pre> <p>I don't get any error, but making this call stops the playback altogether, instead of (as is said in the documentation) continuing playing from the new position. I have tried this also (and many other combinations of the same type):</p> <pre><code>Boolean isPlaying = NO; if (MusicPlayerIsPlaying(musicPlayer, &amp;isPlaying) != noErr) [NSException raise:@"playMIDI:" format:@"Can't get MusicPlayer play state"]; if (isPlaying) { if (MusicPlayerStop(musicPlayer) != noErr) [NSException raise:@"playMIDI:" format:@"Can't stop MusicPlayer"]; } if (MusicPlayerSetSequence(musicPlayer, musicSequence) != noErr) [NSException raise:@"playMIDI:" format:@"Can't set sequence for MusicPlayer"]; if (MusicPlayerSetTime(musicPlayer, (MusicTimeStamp)0.0) != noErr) [NSException raise:@"playMIDI" format:@"Can't reset the player"]; if (MusicPlayerSetPlayRateScalar(musicPlayer, 1.0) != noErr) [NSException raise:@"playMIDI" format:@"Can't set speed"]; if (MusicPlayerStart(musicPlayer) != noErr) [NSException raise:@"playMIDI" format:@"Can't start MusicPlayer"]; </code></pre> <p>No joy, same effect.</p> <p>If I change the MusicSequence however, the new MusicSequence plays fine. So I've gone to the extreme of creating two MusicSequence from the same MIDI file and switching from one to the other. No joy, iOS knows I want to play the same file twice and forbids it. I have to wait until the sequence is completely played before I can play it again. Bewildering.</p> <p>Any idea?</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload