diff --git a/Classes/AudioStreamer.m b/Classes/AudioStreamer.m index 7296b2d..8d88866 100644 --- a/Classes/AudioStreamer.m +++ b/Classes/AudioStreamer.m @@ -1086,8 +1086,7 @@ - (double)calculatedBitRate { if (packetDuration && processedPacketsCount > BitRateEstimationMinPackets) { - double averagePacketByteSize = processedPacketsSizeTotal / processedPacketsCount; - return 8.0 * averagePacketByteSize / packetDuration; + return processedPacketsSizeTotal / processedPacketsCount; } if (bitRate) @@ -1730,7 +1729,7 @@ - (void)handleAudioPackets:(const void *)inInputData if (processedPacketsCount < BitRateEstimationMaxPackets) { - processedPacketsSizeTotal += packetSize; + processedPacketsSizeTotal += 8.0 * packetSize / packetDuration; processedPacketsCount += 1; } diff --git a/Classes/iPhoneStreamingPlayerViewController.m b/Classes/iPhoneStreamingPlayerViewController.m index 4c60558..3b6186d 100644 --- a/Classes/iPhoneStreamingPlayerViewController.m +++ b/Classes/iPhoneStreamingPlayerViewController.m @@ -270,9 +270,9 @@ - (void)updateProgress:(NSTimer *)updatedTimer if (duration > 0) { [positionLabel setText: - [NSString stringWithFormat:@"Time Played: %.1f/%.1f seconds", - progress, - duration]]; + [NSString stringWithFormat:@"Time Played: %@/%@", + [self stringFromTimeInterval:progress], + [self stringFromTimeInterval:duration]]]; [progressSlider setEnabled:YES]; [progressSlider setValue:100 * progress / duration]; } @@ -287,6 +287,17 @@ - (void)updateProgress:(NSTimer *)updatedTimer } } +// +// To get the time formatted in HH:MM:SS format +// Takes a second value, and returns a formatted string +// +- (NSString *)stringFromTimeInterval:(CGFloat)interval { + NSInteger ti = (NSInteger)interval; + NSInteger seconds = ti % 60; + NSInteger minutes = (ti / 60) % 60; + NSInteger hours = (ti / 3600); + return [NSString stringWithFormat:@"%02ld:%02ld:%02ld", (long)hours, (long)minutes, (long)seconds]; +} // // textFieldShouldReturn: //