Why Safari/Chrome can not play the file created using 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.
Here is a sample file: http://cl.ly/1l0z231x322l
Edit: reader code
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).
You could try converting it to .m4a and using the content-type audio/mp4
or converting it .aac and using audio/aac
.
Or .mp3 audio/mpeg
.
PREVIOUSLY
AAC/m4a is not a very widely supported format. You're better off using MP3.
It works if we had the an extension to the URL
recordURL = recordURL.URLByAppendingPathExtension("m4a")
recorder = try AVAudioRecorder(URL: recordURL, settings: AudioRecorder.settings)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.