3

I want to play .opus file using AVAudioPlayer, since AVAudioPlayer doesn't support .opus file, I am trying to find a way to convert .opus to any other audio format so that I can play using AVAudioPlayer. Could anyone help me on this?

Thank you

Rameez
  • 312
  • 4
  • 20
  • 2
    As there is no Apple provided support yet, you can add this dependency https://code.videolan.org/videolan/VLCKit/tree/master#cocoapods – Kamran Oct 10 '18 at 11:23

2 Answers2

0

You could use libopus or libopusfile C libraries to dynamically decode Opus files to raw PCM audio and feed that to a memory buffer that AVAudioPlayer could decode. You would most likely need to prepend the memory buffer with AIFF/WAV/RIFF header bytes that describe the PCM data.

anthumchris
  • 8,245
  • 2
  • 28
  • 53
  • It does not work without 'AIFF/WAV/RIFF header bytes' (as you mentioned). Would you please give me some hints (code sample if possible) here: https://stackoverflow.com/questions/59597315/playing-custom-opus-audio-file-in-ios – MD TAREQ HASSAN Jan 05 '20 at 15:35
0

You could use the VLCKit library ;)

https://code.videolan.org/videolan/VLCKit/blob/master/README.md

rockdaswift
  • 9,613
  • 5
  • 40
  • 46