Playing MP3 (or other compressed audio) files.

Discussion in 'iOS Development' started by Cyanidepoison, Mar 6, 2009.

  1. Cyanidepoison

    Cyanidepoison Active Member

    Joined:
    Jan 18, 2008
    Messages:
    1,076
    Likes Received:
    2
    I've been interested for a while in how to play compressed audio files on the iPhone. I want to write an audio-player daemon for the iPhone (much like MPD, which fell flat on its face when I tried compiling it on my phone) to be used with a GUI front end as a media player, much like what I suspect the built-in media player does.

    Are there any high-level APIs for this? Something like this would be nice (I'd prefer to do this in C/C++ over ObjC, but whatever works):

    Code:
    #include "WhateverINeed.h"
    
    int main(int argc, char *argv[]){
        char *file_path = argv[1];
        NSAudioPlayer *audioPlayer;  //I get how incorrect the syntax is, that isn't the point.
        audioPlayer(file_path);
        audioPlayer.setVolume(argv[2]);
        printf("playing %s",file_path);
        audioPlayer.pause();
    }
    
    Something lower-level would be fine as well (I'll just make a fun little C++ class out of it anyway), I'm just lost in all of silly AudioToolbox stuff here. Heck, I'm lost in all of the iPhone APIs... I'll stick to stdio with my C.
  2. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    AVFoundation.framework. But, I believe that's 2.2+ only. You could also AudioToolbox.framework, and although I've never played with it, CoreAudio.framework might also help.
  3. Cyanidepoison

    Cyanidepoison Active Member

    Joined:
    Jan 18, 2008
    Messages:
    1,076
    Likes Received:
    2
    AVFoundation is exactly what I'm looking for. Thanks.

    Now to figure out how to link against it and find a good toolchain setup...
  4. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    -framework AVFoundation
  5. Cyanidepoison

    Cyanidepoison Active Member

    Joined:
    Jan 18, 2008
    Messages:
    1,076
    Likes Received:
    2
    Well you just have all the answers today.
  6. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    I always have all the answers to the treads on here. It's just that a lot of times I won't respond to the thread if I feel the problem is one the dev should be able to figure out with a little research. Of course, sometimes I feel generous.

    In this case, I'm not sure a lot of people even know about AVFoundation yet. Hence my response.
  7. Cyanidepoison

    Cyanidepoison Active Member

    Joined:
    Jan 18, 2008
    Messages:
    1,076
    Likes Received:
    2
    Google said AudioToolbox... which was a little complicated for my purposes, to say the least.

    Thanks for informing me.

Share This Page