TAAE2: AEAudioFilePlayerModule plays the rest of file from the previous call playAtTime

There is sequence that causes unexpected behaviour:
* set the AEAudioFilePlayerModule properties regionStartTime, regionDuration;
* run playAtTime: ...;
* stop playing before playback has reached the end;
* change regionDuration and relaunch playing:

    filePlayerModule.regionDuration = changedDurationValue;
    [filePlayerModule playAtTime:AETimeStampWithHostTicks(AECurrentTimeInHostTicks()+positionTicks)];

Then we will get playback that begins with "unplayed" rest of the file from previous playback.
What happens: setRegionDuration runs [self schedulePlayRegionFromPosition:_playhead]; where _playhead holds value from previous unfinished playback and sets ScheduledAudioFileRegion for playing the remaining part of the audio from _playhead position. Setting filePlayerModule.currentTime=0 before playAtTime corrects this, but, on the other hand, if we had used filePlayerModule.regionStartTime=changedStartTimeValue everything would have worked perfect without currentTime=0.
Is it the bug?


  • edited September 2016

    I'm not sure I quite understand your dilemma, but one distinction that may be helpful is that a player's currentTime is in relation to the file's entire duration, not the playback region's time interval.

  • @cgmaier said:
    ... player's currentTime is in relation to the file's entire duration, not the playback region's time interval.

    Oh yes, of course. But here currentTime was used just as the way to address the problem. Maybe I didn't describe it clearly. One more example ) :

    run playAtTime:(AETimeStampWithHostTicks(AECurrentTimeInHostTicks() + positionTicks)
    playback is going well ...
    stop playing before the playback has reached the end;
    run again playAtTime:(AETimeStampWithHostTicks(AECurrentTimeInHostTicks() + positionTicks2)

    And I get silence at the output. Has anyone experienced such a thing?

  • How are you maintaining your reference to the player - are you using an AEManagedValue, for example?

  • I use AEArray for set of players

  • But I think it doesn't matter how the player is referenced, because rendering is stopped before restarting the player.

  • One thought is to try creating a new player to play back the second region.

Sign In or Register to comment.