Skip to content

Problem with duration #73

Description

@rastaman111

Hi
There is a file, the audio length does not match the length of the track, I found out and solved this problem using AVAudioFile, it gets the real-time bits, and not the total length

` func getPrecisionDuration(from url: URL) -> TimeInterval? {

    do {
        let audioFile = try AVAudioFile(forReading: url)
        let length = audioFile.length
        let rate = audioFile.processingFormat.sampleRate
        return Double(length) / rate
    } catch {
        print("Не удалось открыть AVAudioFile, пробуем AVAsset: \(error)")
    }
    
    let asset = AVAsset(url: url)
    
    return CMTimeGetSeconds(asset.duration)
}`

I'm attaching audio for testing.
Can you make changes to the player?
Ты была права - Basta (youtube).m4a.zip

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions