Skip to content

Commit

Permalink
error checking to prevent div by 0 with currentTime
Browse files Browse the repository at this point in the history
  • Loading branch information
essej committed Feb 7, 2015
1 parent 6be475d commit b2fa57a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion TheAmazingAudioEngine/AEAudioFilePlayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@ -(NSTimeInterval)duration {
}

-(NSTimeInterval)currentTime {
return ((double)_playhead / (double)_lengthInFrames) * [self duration];
if (_lengthInFrames == 0) return 0.0;
else return ((double)_playhead / (double)_lengthInFrames) * [self duration];
}

-(void)setCurrentTime:(NSTimeInterval)currentTime {
if (_lengthInFrames == 0) return;
_playhead = (int32_t)((currentTime / [self duration]) * _lengthInFrames) % _lengthInFrames;
}

Expand Down

0 comments on commit b2fa57a

Please sign in to comment.