@@ -63,6 +63,7 @@ public class BrightcoveIMAPlayerView extends RelativeLayout implements Lifecycle
63
63
private boolean autoPlay = true ;
64
64
private boolean playing = false ;
65
65
private boolean adsPlaying = false ;
66
+ private boolean inViewPort = true ;
66
67
private boolean disableDefaultControl = false ;
67
68
private int bitRate = 0 ;
68
69
private int adVideoLoadTimeout = 3000 ;
@@ -211,13 +212,15 @@ public void processEvent(Event e) {
211
212
reactContext .getJSModule (RCTEventEmitter .class ).receiveEvent (BrightcoveIMAPlayerView .this .getId (), BrightcoveIMAPlayerViewManager .EVENT_UPDATE_BUFFER_PROGRESS , event );
212
213
}
213
214
});
215
+
214
216
}
215
217
216
218
public void setSettings (ReadableMap settings ) {
217
219
this .settings = settings ;
218
- if (settings != null && settings .hasKey ("autoPlay" )) {
219
- this .autoPlay = settings .getBoolean ("autoPlay" );
220
- }
220
+ // disabling autoPlay coming from settings object
221
+ // if (settings != null && settings.hasKey("autoPlay")) {
222
+ // this.autoPlay = settings.getBoolean("autoPlay");
223
+ // }
221
224
}
222
225
223
226
public void setPolicyKey (String policyKey ) {
@@ -277,6 +280,16 @@ public void toggleFullscreen(boolean isFullscreen) {
277
280
}
278
281
}
279
282
283
+ public void toggleInViewPort (boolean inViewPort ) {
284
+ if (inViewPort ) {
285
+ this .inViewPort = true ;
286
+ } else {
287
+ this .inViewPort = false ;
288
+ // need to pause here also - (differs from IOS behaviour)
289
+ this .pause ();
290
+ }
291
+ }
292
+
280
293
public void setVolume (float volume ) {
281
294
Map <String , Object > details = new HashMap <>();
282
295
details .put (Event .VOLUME , volume );
@@ -319,7 +332,7 @@ public void pause() {
319
332
if (this .brightcoveVideoView != null ) {
320
333
if (this .adsPlaying && this .googleIMAComponent != null ) {
321
334
this .googleIMAComponent .getVideoAdPlayer ().pauseAd ();
322
- } else {
335
+ } else if ( this . playing ) {
323
336
this .brightcoveVideoView .pause ();
324
337
}
325
338
}
@@ -328,7 +341,6 @@ public void pause() {
328
341
public void play () {
329
342
if (this .brightcoveVideoView != null ) {
330
343
if (this .adsPlaying && this .googleIMAComponent != null ) {
331
- //this.brightcoveVideoView.pause();
332
344
this .googleIMAComponent .getVideoAdPlayer ().resumeAd ();
333
345
} else {
334
346
this .brightcoveVideoView .start ();
@@ -400,7 +412,7 @@ private void fixVideoLayout() {
400
412
}
401
413
402
414
/*
403
- This methods show how to the the Google IMA AdsManager, get the cue points and add the markers
415
+ This methods show how to get the Google IMA AdsManager, get the cue points and add the markers
404
416
to the Brightcove Seek Bar.
405
417
*/
406
418
private void setupAdMarkers (BaseVideoView videoView ) {
@@ -416,7 +428,6 @@ private void setupAdMarkers(BaseVideoView videoView) {
416
428
// If cuepoint is negative it means it is a POST ROLL.
417
429
int markerTime = cuepoint < 0 ? brightcoveSeekBar .getMax () : (int ) (cuepoint * DateUtils .SECOND_IN_MILLIS );
418
430
mediaController .getBrightcoveSeekBar ().addMarker (markerTime );
419
-
420
431
}
421
432
});
422
433
videoView .setMediaController (mediaController );
@@ -444,9 +455,7 @@ private void setupGoogleIMA() {
444
455
adsPlaying = false ;
445
456
});
446
457
447
- // Set up a listener for initializing AdsRequests. The Google
448
- // IMA plugin emits an ad request event as a result of
449
- // initializeAdsRequests() being called.
458
+ // Set up a listener for initializing AdsRequests.
450
459
eventEmitter .on (GoogleIMAEventType .ADS_REQUEST_FOR_VIDEO , event -> {
451
460
String IMAUrl = settings != null && settings .hasKey ("IMAUrl" ) ?
452
461
settings .getString ("IMAUrl" ) : "" ;
@@ -481,18 +490,16 @@ private void setupGoogleIMA() {
481
490
482
491
@ Override
483
492
public void onHostResume () {
484
- if (this .adsPlaying && this .googleIMAComponent != null && googleIMAComponent .getVideoAdPlayer () != null ) {
485
- this .googleIMAComponent .getVideoAdPlayer ().playAd ();
486
- } else if (this .playing && this .brightcoveVideoView != null ) {
487
- this .brightcoveVideoView .start ();
488
- }
493
+ // handleAppStateDidChange active
494
+ this .pause ();
495
+ this .toggleInViewPort (true );
489
496
}
490
497
491
498
@ Override
492
499
public void onHostPause () {
493
- if ( this . adsPlaying && this . googleIMAComponent != null && googleIMAComponent . getVideoAdPlayer () != null ) {
494
- googleIMAComponent . getVideoAdPlayer () .pause ();
495
- }
500
+ // handleAppStateDidChange background
501
+ this .pause ();
502
+ this . toggleInViewPort ( false );
496
503
}
497
504
498
505
@ Override
0 commit comments