Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9125847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:53:57+00:00 2026-06-17T06:53:57+00:00

I’ve been playing around with the iOS SDK for a few days now, and

  • 0

I’ve been playing around with the iOS SDK for a few days now, and am getting to the point where I’m starting to put the concepts and approaches I’ve learnt by writing a noddy little application which displays what the currently playing song from the music library is on my iPhone.

The problem I’ve hit is that whilst there are delegate methods on AVAudioPlayerDelegate for when a piece of audio finishes playing, I can’t seem to find any references for any notifications / events/ delegate methods that are called and can be hooked into / listened for when a piece of audio STARTS playing – i.e. when the user presses the play button, or even just the track changes.

After doing 3 whole days (!!!) of iOS dev and playing around, there is clearly going to be a way to do it, but I’m not sure what / where to find it. Aside from having a push button on my UI as I do at the moment to populate the information (which works fine, the back-end code does what it’s meant to), the only other approach I can see is to hook into the ‘track finished playing’ method on the aforementioned delegate and use that.

But that seems a bit hacky.

UPDATED

Well, I think I momentarily went full retard. This is what you get for fiddling with iOS for the first time with a Java background. I implemented your suggestion (with some syntactic tweaks) as follows:

h file:

#import <Foundation/Foundation.h>
#import <AVFoundation/AVAudioPlayer.h>

@protocol GeoTunesAVAudioPlayerDelegate <AVAudioPlayerDelegate>

-(void)didStartPlaying;

@end

@interface GeoTunesAVAudioPlayer : AVAudioPlayer <AVAudioPlayerDelegate>

@end

and m file:

 #import "GeoTunesAVAudioPlayer.h"

@implementation GeoTunesAVAudioPlayer

- (id)init
{
    self = [super init];

    return self;
}

- (BOOL) play
{


    if ([[self delegate] respondsToSelector:@selector(didStartPlaying)])
    {
        [(id)[self delegate] didStartPlaying];
    }

    return [super play];

}


@end

And I implement this in my Controller with:

 // Set up the audio delegate
 player = [[GeoTunesAVAudioPlayer alloc] init];
 player.delegate = self;

But this little arrangement craps out with EXC_BAD_ACCESS, which is frustrating as I don’t understand enough about what’s going on behind the scenes here to even assess what the problem is. Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:53:58+00:00Added an answer on June 17, 2026 at 6:53 am

    I don’t think it’s available! Here’s an idea though:

    1. Subclass AVAudioPlayer
    2. Extend the protocol
    3. Add a new delegate method
    4. Override play and implement you delegate method and call super

    General idea: (warning, syntax might be wrong!)

        // .h
    
        @protocol AVAudioPlayerSubDelegate <AVAudioPlayerDelegate>
           -(void)didStartPlaying;
        @end
    
        @interface AVAudioPlayerSub : AVAudioPlayer;
    
       // .m
    
        @implementation AVAudioPlayerSub
    
        - (void) play
    
           if ([delegate respondsToSelector:@selector(didStartPlaying)]){
              [(id)delegate didStartPlaying];
           }
    
           [super play];
    
        }
    

    EDIT after comments:

    I think your subclass of AVAudioPlayer (GeoTunesAVAudioPlayer) class should not conform to AVAudioPlayerDelegate as this is the delegating class. You should have the controller that contains the player object conforming to your subprotocol GeoTunesAVAudioPlayerDelegate

    //.h

    #import <Foundation/Foundation.h>
    #import <AVFoundation/AVAudioPlayer.h>
    
    @protocol GeoTunesAVAudioPlayerDelegate <AVAudioPlayerDelegate>
    
    -(void)didStartPlaying;
    
    @end
    
    @interface GeoTunesAVAudioPlayer : AVAudioPlayer
    
    @end
    

    and m file:

    #import "GeoTunesAVAudioPlayer.h"
    
    @implementation GeoTunesAVAudioPlayer
    
    - (id)init
    {
        self = [super init];
    
        return self;
    }
    
    - (BOOL) play
    {
        if ([[self delegate] respondsToSelector:@selector(didStartPlaying)])
        {
            [(id)[self delegate] didStartPlaying];
        }
    
        return [super play];
    
    }
    
    @end
    

    and in your controller:

    //.h
    @interface MyViewController : UIViewController <GeoTunesAVAudioPlayerDelegate>
    
    //.m
    
    player = [[GeoTunesAVAudioPlayer alloc] init];
    player.delegate = self;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have been unable to fix a problem with Java Unicode and encoding. The
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am trying to loop through a bunch of documents I have to put
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.