0

Adcolony is a video advert platform integrated into Xcode to play ads to users in video and sound,

One of the requirements is to block audio when the add starts playing,

This is the audio:

 //Audio Sound On - uncomment
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
                                  pathForResource:@"soundTrack"
                                  ofType:@"mp3"]];
audioPlayer = [[AVAudioPlayer alloc]
                           initWithContentsOfURL:url
                          error:nil];

it starts as soon as the game starts, in view controller,

The triggerVideo action is place in PlayViewController and needs to be set off when ad is triggered,

- (IBAction)TriggerVideo:(id)sender {
[AdColony playVideoAdForZone:@"ZONE-NUMBER-HERE" withDelegate:nil];
}

I've left this aside for a while now, wondering if anyone knows how to employ this function?

6
  • try audioPlayer.volume = 0.0f;
    – MDB983
    Apr 29, 2014 at 21:51
  • how do I bring it back after Apr 29, 2014 at 22:51
  • audiPlayer.volume = 1.0f
    – MDB983
    Apr 29, 2014 at 23:10
  • No where do I put this code? Apr 29, 2014 at 23:11
  • set volume to 0 in the delegate methode - (void) onAdColonyAdStartedInZone:(NSString *)zoneID .... and once it's finished playing ads, it will call the - (void) onAdColonyAdAttemptFinished:(BOOL)shown inZone:(NSString *)zoneID delegate method so place the volume = 1 in that method.
    – MDB983
    Apr 29, 2014 at 23:18

1 Answer 1

0

add these methods to your viewController that's the delegate for adcolony, which should also be the viewcontroller in which you initialize the AVAudioPlayer. I probably don't need to state this, but i'm assuming you have an @Property for your audioPlayer

- (void) onAdColonyAdStartedInZone:(NSString *)zoneID{
  self.audioPlayer.volume = 0.0f;
}

- (void) onAdColonyAdAttemptFinished:(BOOL)shown inZone:(NSString *)zoneID{
  self.audioPlayer.volume = 1.0f;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.