22

Has anyone played an ogg stream from iOS? What can I use without having to write my own decoder?

I'm using Apple's AVPlayer to play the stream.

This question has been asked as part of this thread: iOS online radio streaming questions but it hasn't been answered.

Community
  • 1
  • 1
nnyby
  • 4,748
  • 10
  • 49
  • 105
  • Checkout my [answer](http://stackoverflow.com/questions/4745618/ogg-vorbis-in-iphone-sdk/10176902#10176902). It's not about stream, but might be useful. – DanSkeel May 30 '12 at 07:08

3 Answers3

22

There is no built-in support for playing ogg files in iOS, however, the source code for ogg compression/decompression is readily available (from xiph.com). It is fairly straightforward to compile this code for iOS and use it in an app.

I had a chance to compile the libraries and have made them available: "Precompiled Ogg Vorbis Libraries for iOS".

I have also made some sample source code available on GitHub that shows how to play decoded Ogg Vorbis audio on iOS: IDZAQAudioPlayer

Michael Kohne
  • 11,888
  • 3
  • 47
  • 79
idz
  • 12,825
  • 1
  • 29
  • 40
  • 1
    How can I use your Precompiled Ogg Vorbis libraries in iOS – user777304 Apr 04 '13 at 04:05
  • 1
    How can I use your Precompiled Ogg Vorbis libraries in iOS – user777304 Apr 05 '13 at 14:02
  • @user777304 You will need to use Audio Queues or OpenAL to play back the decompressed audio. – idz Apr 05 '13 at 21:48
  • @user777304 Just put up some code on GitHub that demonstrates how to play back on iOS. See the link in my updated answer. – idz Apr 06 '13 at 01:21
  • Is it possible to use AVAudioPlayer to play the decompressed audio? Your code is quite complex, I'm hoping I don't have to go that complex just to play a simple ogg file. – muttley91 Sep 03 '13 at 03:14
  • 1
    @rar Not really. You could decompress the entire file and play that view AVAudioPlayer, but that would introduce quite a log. The code I published is the simplest way (I know of) of pipelining the decompression and playback. Not sure why you think it is complex. Takes 4 lines of code to set up the player. Then you call things like [player play] and [player stop]! – idz Sep 04 '13 at 00:46
  • @idz, really appreciate your effort to compile these libraries for armv7 and i386 platform. These precompiled libraries are missing arm64 and x86_64 architectures. I tried to compile these libraries unsuccessfully for these platforms. Were you able to compile these libraries for arm64 and x86_64 architectures/platforms? – sarabdeep singh Oct 28 '15 at 16:55
2

.ogg file may also be encoded in Opus or FLAC, refer to Ogg wiki. IDZAQAudioPlayer may not cover all cases.

For Opus codec, you may refer Telegram for iPhone source code: https://telegram.org/apps

liruqi
  • 1,524
  • 15
  • 12
0

Use the VLCKit – ibvlc bindings for macOS, iOS, iPadOS and tvOS in Objective-C.

It's a library from the well-known media player "VLC Media Player," and it supports Cocoapods and can play/stream .ogg files on iOS seamlessly.

  pod 'MobileVLCKit'

Check out this blog post for a more detailed tutorial.

Ajith Renjala
  • 4,934
  • 5
  • 34
  • 42