dmrschmidt / DSWaveformImage

Generate waveform images from audio files on iOS, macOS & visionOS in Swift. Native SwiftUI & UIKit views.
MIT License
978 stars 109 forks source link

I need to show loader till complete image generating from audio URL. #86

Closed SantoshProdev closed 7 months ago

SantoshProdev commented 7 months ago
        let asset = AVURLAsset(url: url)
        let width = (SCREENWIDTH() * CGFloat(Double(CMTimeGetSeconds(asset.duration))))/self.vdoDur
        let x = (SCREENWIDTH() - 170)/2
        self.waveformImageView = WaveformImageView(frame: CGRect(x: x, y: 15, width: width, height: 20))
        self.waveformImageView.configuration = Waveform.Configuration(
            backgroundColor: .clear,
            style: .striped(.init(color: UIColor(red: 209/255.0, green: 209/255.0, blue: 209/255.0, alpha: 1), width: 5, spacing: 5)),
            verticalScalingFactor: 0.5
        )
        self.waveformImageView.waveformAudioURL = url

how can i know image is loaded via audio URL. Can you help me find solution of this?

dmrschmidt commented 7 months ago

Hey @software124. For UIKit, this is not currently supported by WaveformImageView. It is supported in SwiftUI's WaveformView (see last example there in the linked README).

Using SwiftUI would be my recommended approach.

If you cannot use SwiftUI, the best alternative is using standard UIImageViews in conjunction with WaveformImageDrawer

SantoshProdev commented 7 months ago

Thank you @dmrschmidt.