1
1
///<reference path='./google.ima.ts'/>
2
- import { Component , ElementRef , Input , HostBinding , ViewEncapsulation , OnInit , OnDestroy } from '@angular/core' ;
2
+ import { Component , ElementRef , Input , HostBinding , ViewEncapsulation , OnInit , OnDestroy , Output , EventEmitter } from '@angular/core' ;
3
3
import { IPlayable } from '../core/vg-media/i-playable' ;
4
4
import { VgAPI } from '../core/services/vg-api' ;
5
5
import { VgEvents } from '../core/events/vg-events' ;
@@ -34,6 +34,10 @@ export class VgImaAds implements OnInit, OnDestroy {
34
34
@Input ( ) vgAdTagUrl : string ;
35
35
@Input ( ) vgSkipButton : string ;
36
36
37
+ @Output ( ) onAdStart : EventEmitter < boolean > = new EventEmitter ( ) ;
38
+ @Output ( ) onAdStop : EventEmitter < boolean > = new EventEmitter ( ) ;
39
+ @Output ( ) onSkipAd : EventEmitter < boolean > = new EventEmitter ( ) ;
40
+
37
41
elem : HTMLElement ;
38
42
target : IPlayable ;
39
43
ima : Ima ;
@@ -225,15 +229,18 @@ export class VgImaAds implements OnInit, OnDestroy {
225
229
226
230
onClickSkip ( ) {
227
231
this . ima . adsManager . skip ( ) ;
232
+ this . onSkipAd . emit ( true ) ;
228
233
}
229
234
230
235
onContentPauseRequested ( ) {
231
236
this . show ( ) ;
232
237
this . API . pause ( ) ;
238
+ this . onAdStop . emit ( true ) ;
233
239
}
234
240
235
241
onContentResumeRequested ( ) {
236
242
this . API . play ( ) ;
243
+ this . onAdStart . emit ( true ) ;
237
244
this . hide ( ) ;
238
245
}
239
246
@@ -243,19 +250,22 @@ export class VgImaAds implements OnInit, OnDestroy {
243
250
}
244
251
this . hide ( ) ;
245
252
this . API . play ( ) ;
253
+ this . onAdStop . emit ( true ) ;
246
254
}
247
255
248
256
onAllAdsComplete ( ) {
249
257
this . hide ( ) ;
250
258
// The last ad was a post-roll
251
259
if ( this . ima . adsManager . getCuePoints ( ) . join ( ) . indexOf ( '-1' ) >= 0 ) {
252
260
this . API . pause ( ) ; // it was stop() in Videogular v1
261
+ this . onAdStop . emit ( true ) ;
253
262
}
254
263
}
255
264
256
265
onAdComplete ( ) {
257
266
// TODO: Update view with current ad count
258
267
this . ima . currentAd ++ ;
268
+ this . onAdStop . emit ( true ) ;
259
269
}
260
270
261
271
show ( ) {
@@ -270,6 +280,7 @@ export class VgImaAds implements OnInit, OnDestroy {
270
280
271
281
onContentEnded ( ) {
272
282
this . ima . adsLoader . contentComplete ( ) ;
283
+ this . onAdStop . emit ( true ) ;
273
284
}
274
285
275
286
onChangeFullscreen ( fsState : boolean ) {
0 commit comments