[Help Please] How-To manage AVAudioPlayer

Discussion in 'iOS Development' started by cocotutch, Aug 19, 2009.

  1. cocotutch

    cocotutch Community Development Team Staff Member

    Joined:
    Oct 6, 2008
    Messages:
    1,285
    Likes Received:
    117
    Device:
    5G iPod touch
    OK,

    I have an app, where I coded an Audio Player to play a 1:15 min MP3 File. It works, with Stop, Play and Pause, but I want to have it automatically check if the Player Instance has stopped playing by itself without Interruption.

    I found this:

    [OBJC]- (void)audioPlayerDidFinishPlaying

    Please Register or Log in to view images

    AVAudioPlayer *)player successfully

    Please Register or Log in to view images

    BOOL)flag[/OBJC]

    Inside the Docs, and I am assuming this is the function I need to use, but I have no idea on how to make the player call it upon the Audio File finishing by itself. Help please?

    cocotutch
  2. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    • Flaming and/or trolling
    Seriously, read the Apple docs and guides on things before coming here. You ask questions that are so silly they are near common sense, or at least should be. Go read about delegates.
  3. cocotutch

    cocotutch Community Development Team Staff Member

    Joined:
    Oct 6, 2008
    Messages:
    1,285
    Likes Received:
    117
    Device:
    5G iPod touch
    Were you reading? I found that in the Docs, but I do NOT understand how to check whether the song has finished or not. Why were you so condescending? Just because you know how to code like a flaming pro, doesn't mean the rest of us do. Get over the fact that people ask questions when they may seem silly or irrelevant in your eyes, next time you ask a question (if you ever do), I can tell you, I will give you a right mouthful since you deserve it and I didn't.

    Thank-you and have a nice day,

    cocotutch
  4. Cyanidepoison

    Cyanidepoison Active Member

    Joined:
    Jan 18, 2008
    Messages:
    1,076
    Likes Received:
    2
    This is like Objectice-C 101 type stuff you're asking questions about.
  5. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    Cocoatouch, in the future, instead of responding to attitudes with an attitude yourself, let a moderator know.

    To answer your question, you will need to make your object conform to that object's delegation protocol, assign your object as that object's delegate, and simply take that method posted and place it in your object's code. the method will be called, adn you may do as you wish from that point on.

    This is the same way a UITableView works with its delegate and datasource.
  6. cocotutch

    cocotutch Community Development Team Staff Member

    Joined:
    Oct 6, 2008
    Messages:
    1,285
    Likes Received:
    117
    Device:
    5G iPod touch
    Ah. That seemed to solve it. I should have included more information in the original post, that method, I was unsure if I had to put a BOOL in there to check whether it was successful or not. It worked anyway, thank-you.

    And yes, in the future, I will refer any issues to a moderator.

    Please Register or Log in to view images



    Thanks again,

    cocotutch

Share This Page