@@ -60,11 +60,14 @@ - (void)setupWithSettings:(NSDictionary*)settings {
60
60
imaSettings.ppid = kViewControllerIMAPublisherID ;
61
61
}
62
62
imaSettings.language = kViewControllerIMALanguage ;
63
+ imaSettings.autoPlayAdBreaks = NO ;
63
64
64
65
IMAAdsRenderingSettings *renderSettings = [[IMAAdsRenderingSettings alloc ] init ];
65
66
renderSettings.linkOpenerPresentingController = RCTPresentedViewController ();
66
67
renderSettings.linkOpenerDelegate = self;
68
+ renderSettings.enablePreloading = YES ; // default is yes anyway
67
69
70
+ // Timeout (in seconds) when loading a video ad media file. If loading takes longer than this timeout, the ad playback is canceled and the next ad in the pod plays, if available. Use -1 for the default of 8 seconds.
68
71
if (_targetAdVideoLoadTimeout == 0 ) {
69
72
renderSettings.loadVideoTimeout = 3 .;
70
73
} else {
@@ -96,7 +99,7 @@ - (void)setupWithSettings:(NSDictionary*)settings {
96
99
[[AVAudioSession sharedInstance ] setCategory: AVAudioSessionCategoryPlayback error: &error];
97
100
98
101
BOOL autoAdvance = [settings objectForKey: @" autoAdvance" ] != nil ? [[settings objectForKey: @" autoAdvance" ] boolValue ] : NO ;
99
- BOOL autoPlay = [settings objectForKey: @" autoPlay" ] != nil ? [[settings objectForKey: @" autoPlay" ] boolValue ] : YES ;
102
+ BOOL autoPlay = NO ; // [settings objectForKey:@"autoPlay"] != nil ? [[settings objectForKey:@"autoPlay"] boolValue] : YES;
100
103
BOOL allowsExternalPlayback = [settings objectForKey: @" allowsExternalPlayback" ] != nil ? [[settings objectForKey: @" allowsExternalPlayback" ] boolValue ] : YES ;
101
104
102
105
_playbackController.autoAdvance = autoAdvance;
@@ -238,6 +241,8 @@ -(void) toggleInViewPort:(BOOL)inViewPort {
238
241
_inViewPort = YES ;
239
242
} else {
240
243
_inViewPort = NO ;
244
+ [self .playbackController pauseAd ];
245
+ [self .playbackController pause ];
241
246
}
242
247
}
243
248
@@ -254,8 +259,9 @@ -(void) play {
254
259
if (self.playbackController ) {
255
260
if (_adsPlaying) {
256
261
[self .playbackController resumeAd ];
257
- [self .playbackController pause ];
262
+ // [self.playbackController pause];
258
263
} else {
264
+ // if ad hasnt started, this will kick it off
259
265
[self .playbackController play ];
260
266
}
261
267
}
@@ -291,6 +297,8 @@ - (void)handleAppStateDidChange:(NSNotification *)notification
291
297
#pragma mark - BCOVPlaybackControllerBasicDelegate methods
292
298
293
299
- (void )playbackController : (id <BCOVPlaybackController>)controller playbackSession : (id <BCOVPlaybackSession>)session didReceiveLifecycleEvent : (BCOVPlaybackSessionLifecycleEvent *)lifecycleEvent {
300
+
301
+ // NSLog(@"BC - DEBUG eventType: %@", lifecycleEvent.eventType);
294
302
295
303
if (lifecycleEvent.eventType == kBCOVPlaybackSessionLifecycleEventPlaybackBufferEmpty ||
296
304
lifecycleEvent.eventType == kBCOVPlaybackSessionLifecycleEventFail ||
@@ -333,20 +341,26 @@ - (void)playbackController:(id<BCOVPlaybackController>)controller playbackSessio
333
341
self.onPause (@{});
334
342
}
335
343
} else if (lifecycleEvent.eventType == kBCOVIMALifecycleEventAdsLoaderLoaded ) {
336
- if (self.onAdStarted ) {
337
- self.onAdStarted (@{});
344
+ if (self.onAdsLoaded ) {
345
+ self.onAdsLoaded (@{});
338
346
}
339
347
} else if (lifecycleEvent.eventType == kBCOVPlaybackSessionLifecycleEventAdProgress ) {
340
348
// catches scroll away before ads start bug
341
349
if (!_inViewPort) {
342
350
[self .playbackController pauseAd ];
351
+ [self .playbackController pause ];
343
352
}
344
- } else if (lifecycleEvent.eventType == kBCOVIMALifecycleEventAdsManagerDidReceiveAdEvent ) {
353
+ }
354
+
355
+ if (lifecycleEvent.eventType == kBCOVIMALifecycleEventAdsManagerDidReceiveAdEvent ) {
345
356
IMAAdEvent *adEvent = lifecycleEvent.properties [@" adEvent" ];
357
+
358
+ // NSLog(@"BC - DEBUG adEvent: %ld %@", adEvent.type, adEvent.typeString);
346
359
347
360
switch (adEvent.type )
348
361
{
349
362
case kIMAAdEvent_LOADED :
363
+ _adsPlaying = YES ;
350
364
break ;
351
365
case kIMAAdEvent_PAUSE :
352
366
break ;
@@ -417,35 +431,35 @@ -(void)playerView:(BCOVPUIPlayerView *)playerView didTransitionToScreenMode:(BCO
417
431
#pragma mark - BCOVPlaybackControllerAdsDelegate methods
418
432
419
433
- (void )playbackController : (id <BCOVPlaybackController>)controller playbackSession : (id <BCOVPlaybackSession>)session didEnterAdSequence : (BCOVAdSequence *)adSequence {
420
- if (!_inViewPort && _adsPlaying ) {
434
+ if (!_inViewPort) {
421
435
[self .playbackController pauseAd ];
422
436
}
423
- [self .playbackController pause ];
437
+ // [self.playbackController pause];
424
438
}
425
439
426
440
- (void )playbackController : (id <BCOVPlaybackController>)controller playbackSession : (id <BCOVPlaybackSession>)session didExitAdSequence : (BCOVAdSequence *)adSequence {
427
- if (_inViewPort) {
428
- [self .playbackController play ];
429
- }
441
+ // if (_inViewPort) {
442
+ // [self.playbackController play];
443
+ // }
430
444
}
431
445
432
446
- (void )playbackController : (id <BCOVPlaybackController>)controller playbackSession : (id <BCOVPlaybackSession>)session didEnterAd : (BCOVAd *)ad {
433
- if (!_inViewPort && _adsPlaying ) {
434
- [self .playbackController pauseAd ];
435
- }
436
- [self .playbackController pause ];
447
+ // if (!_inViewPort) {
448
+ // [self.playbackController pauseAd];
449
+ // }
450
+ // [self.playbackController pause];
437
451
}
438
452
439
453
- (void )playbackController : (id <BCOVPlaybackController>)controller playbackSession : (id <BCOVPlaybackSession>)session didExitAd : (BCOVAd *)ad {
440
- if (_inViewPort) {
441
- [self .playbackController play ];
442
- }
454
+ // if (_inViewPort) {
455
+ // [self.playbackController play];
456
+ // }
443
457
}
444
458
445
459
- (void )playbackController : (id <BCOVPlaybackController>)controller playbackSession : (id <BCOVPlaybackSession>)session ad : (BCOVAd *)ad didProgressTo : (NSTimeInterval )progress {
446
- if (_playing) {
447
- [self .playbackController pause ];
448
- }
460
+ // if (_playing) {
461
+ // [self.playbackController pause];
462
+ // }
449
463
}
450
464
451
465
#pragma mark - IMAPlaybackSessionDelegate Methods
0 commit comments