简体   繁体   English

iOS音频文件无法在桌面网络浏览器中播放

[英]iOS audio file not playing in a desktop web browser

Why Safari/Chrome can not play the file created using AVAudioRecorder ? 为什么Safari / Chrome无法播放使用AVAudioRecorder创建的文件?

Here's my recorder settings : 这是我的录音机设置:

private static let settings = [
        AVFormatIDKey: NSNumber(unsignedInt: kAudioFormatMPEG4AAC),
        AVNumberOfChannelsKey: 2,
        AVSampleRateKey: 44100,
        AVEncoderBitRateKey: 128000,
        AVEncoderAudioQualityKey: NSNumber(long: AVAudioQuality.Max.rawValue)
    ]

And the reader : 和读者:

<audio controls>
  <source src="MD_31E5106A-2901-49ED-8492-D29A654B826D" type="audio/mp4">
</audio>

I tried several settings, no success. 我尝试了几种设置,但没有成功。 All files are playable with VLC. 所有文件均可在VLC中播放。

Here is a sample file: http://cl.ly/1l0z231x322l 这是一个示例文件: http : //cl.ly/1l0z231x322l

Edit: reader code 编辑:读者代码

UPDATE UPDATE

Your file is a CAF/Core Audio Format , and AAC/caf is even less widely supported than AAC/m4a (not even iTunes plays caf files). 您的文件是CAF /核心音频格式 ,与AAC / m4a相比,AAC / caf的支持范围甚至更广(甚至iTunes都不播放caf文件)。

You could try converting it to .m4a and using the content-type audio/mp4 or converting it .aac and using audio/aac . 您可以尝试将其转换为.m4a并使用内容类型audio/mp4或者将其转换为.aac并使用audio/aac

Or .mp3 audio/mpeg . 或.mp3 audio/mpeg

PREVIOUSLY 先前

AAC/m4a is not a very widely supported format. AAC / m4a并不是一种广泛支持的格式。 You're better off using MP3. 最好使用MP3。

It works if we had the an extension to the URL 如果我们对URL进行了扩展,就可以使用

recordURL = recordURL.URLByAppendingPathExtension("m4a") 
recorder = try AVAudioRecorder(URL: recordURL, settings: AudioRecorder.settings)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM