ios - 将通过AlamoFire下载的MPEG音频文件转换为mp3文件

标签 ios swift audio alamofire mp3

我正在使用Alamofire API在我的iOS项目中下载内容。效果很好,但我只想下载音频内容并将其作为mp3存储到我的文件目录中。 mp3文件下载很好,但是存在一些我想下载的音频内容,并且没有路径扩展名。没有扩展名的Audi内容将下载并仍可以从我的AVAudioPlayer()播放,但是我还需要将这些文件转换为mp3。
有没有办法将这些没有扩展名的音频文件转换为mp3?我尝试仅添加“.mp3”路径扩展名,但我认为并不是那么简单。任何帮助将不胜感激。

// Download Destination 
let dest: DownloadRequest.DownloadFileDestination = { _, _ in
            let documentsURL:NSURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! as NSURL
            print("***documentURL: ",documentsURL)
            let fileURL = documentsURL.appendingPathComponent(url.lastPathComponent)
            print("***fileURL: ",fileURL ?? "")
            return (fileURL!,[.removePreviousFile, .createIntermediateDirectories])
        }

// Download Operation        
Alamofire.download(url, to: dest)
            .downloadProgress(closure: {(progress) in
                print("Progress: \(progress.fractionCompleted)")
                self.appDelegate.downloadProgressQueue[url] = Float(progress.fractionCompleted)
            }).validate(contentType: ["audio/mpeg"])
            .response(completionHandler: {(complete) in
                if complete.error == nil, let filePath = complete.destinationURL?.path {
 
                   // Download Completed
 
                }
                else {
                    
                   // Download Unsuccessful

                }
        })

最佳答案

adding the ".mp3" path extension


不会更改文件格式。
您应该转换音频文件。但是您无法在iOS设备上创建.mp3文件。

关于ios - 将通过AlamoFire下载的MPEG音频文件转换为mp3文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62587007/

相关文章:

ios - Swift,无法使用 'deep link' 打开第二个应用程序

c# - C#应用程序:从音频输出采样音频-> FFT算法->可视化

C编程: How do I play audio files?

ios - 如何以编程方式滚动到 uitableView 标题

java - 如何使用 Selenium 在 iPhone 中执行 ENTER 键操作

swift - 在 swift3 中不使用 Uiimageview 更改 UIImage 颜色

ios - 为什么 NSDate 字符串中有一些奇怪的字符

android - 无法修复错误的数据库均方根刻度

ios - 区分记录类型和 iCloud 发送的通知

ios - UITableViewCell 子类不允许我设置标签文本