Question

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?

Was it helpful?

Solution

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;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top