fulldecent/FDWaveformView

BLOCKED ON ISSUE 139 ## Are there any examples of the waveform progress updating as an audio file plays?

sumitpaul opened this issue · 2 comments

I looked at the "Examples" folder in the repo but it's not very clear how this would work with a playing audio. I am able to display the waveform and I can tap to change the highlighted part of the waveform, but I can't figure out how to connect this progress to the playing audio file. Please help.

Any progress ?

Hi there,

I know this is probably no longer needed by either of you but perhaps this can help a future user:

  1. In viewDidLoad(), add your FDWaveformView as per your specification (in this example, I used interface builder and my IBOutlet is called waveView). Ensure scrolling is enabled for your waveform:

image

  1. I'm using a button to trigger playback in this example. Upon pressing the button when no file is playing, I call this function. The animation time parameter is set to equal the length of the audio file for fairly obvious reasons. (NOTE: without the .curveLinear option, the 'scroll' will be out-of-sync. This was unfortunately not apparent in the example project but thankfully I realised it was a non-linear response after some trial and error):

image

  1. Upon finishing the audio playback, I reset the 'progress' by triggering this method:

image

Hopefully this helps! I'm fairly new to software development so forgive me if there's any glaring 'no-no's.

EDIT:

I've found that stopping this animation in the middle can be glitchy at best. My code is now using UIViewPropertyAnimator which is working perfectly:

image