문제

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?

도움이 되었습니까?

해결책

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;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top