iOS and decoding MP3/AAC data from memory buffer
Forgive me, I very new at iOS – and programming at this scale in general.
I have been digging through iOS documentation, I know there are some functions like ExtAudiofile… for decoding MP3/AAC files, but are there any that will operate on Mp3/aac data that’s already in memory?
I will probably have to extract the media data (byte by byte; iOS does allow that right?) from inside another file, so I can’t just give it the URL.
Edit: the mp3 data will be in a non-standard file format, Apple provided function should not be able to read them. I heard iOS has a hardware decoder that works on one audio stream and the OS will fallback to software decoding if there are multiple streams.
I would rather use what Apple provides then integrate a MP3 decoder into the app.
- UIDatePicker memory leak in IOS 8.3
- updatesearchresultsforsearchcontroller not called
- MUC How-to with XMPPFramework
- How to figure out when a HTML5 video player enters the full screen mode on iOS / iPads?
- Custom tab bar background image - in iOS 4.x
- Adding same button to all view controllers in UINavigationController
Solutions Collect From Internet About “iOS and decoding MP3/AAC data from memory buffer”
You can use ExtAudioFileRead to read a file that is in memory, but you have to use AudioFileOpenWithCallbacks. I’m not by my work computer so I can’t give you exact code, but here’s the general process:
- Use fopen/fread to read the given file into a memory buffer array. Use a simple C array and not an NSArray or NSData – you need speed and you need for it to be compatible with the next step.
- Create some basic C function callbacks for read / get size.
- Use AudioFileOpenWithCallbacks with the callbacks you wrote to open
the audio file in memory.
- Use ExtAudioFileWrapAudioFileID to start decoding the file in memory.
This is in replacement of ExtAudioFileOpenURL.
If you Google +AudioFileOpenWithCallbacks +ExtAudioFileWrapAudioFileID, you’ll find that some folks have already done this and published their code.
I’m not sure what you mean by non-standard mp3 data, so you should try to play the file using another app to see if it will be compatible.
- PayPal API : How to integrate it in my App? IOS5
- View height problems (continued)
- Why can't I pass a Protocol.Type to a generic T.Type parameter?
- Are cookies in UIWebView accepted?
- Sharing image and text to Facebook Messenger with UIActivityViewController failing
- how to display nested array data inside uitableview properly with Multiple level of Sections
- Append String in Swift
- AFNetworking : How to know if response is using cache or not ? 304 or 200
- Swift error: missing argument label 'name:' in call
- Xcode 4 idekeybindings multiple commands for one keystroke
- view of the page broken when personal hotspot feature turned on
- What exactly does removedOnCompletion = NO do?
- Getting data from findObjectsInBackgroundWithBlock in swift
- iPhone Custom Fonts with Font Suitcase
- AVPlayerViewController in UICollectionViewCell bug?