|
@@ -1,5 +1,6 @@
|
|
|
-import { Component, OnInit } from '@angular/core';
|
|
|
+import { Component, Input, OnInit } from '@angular/core';
|
|
|
import { MessageService } from '../../../services/message.service';
|
|
|
+declare const Vap: any;
|
|
|
@Component({
|
|
|
selector: 'app-flutter-comp',
|
|
|
templateUrl: './flutter-comp.component.html',
|
|
@@ -8,11 +9,48 @@ import { MessageService } from '../../../services/message.service';
|
|
|
imports: []
|
|
|
})
|
|
|
export class FlutterCompComponent implements OnInit {
|
|
|
-
|
|
|
+ @Input('domId') domId: string = 'vap-gift'
|
|
|
constructor(
|
|
|
public msgSerrvice: MessageService
|
|
|
- ) { }
|
|
|
-
|
|
|
+ ) {
|
|
|
+ this.msgSerrvice.eventplay$.subscribe((data) => {
|
|
|
+ this.playGift(data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ playGift(giftModule:any){
|
|
|
+ console.log(giftModule);
|
|
|
+ this.msgSerrvice.isPlayer = true
|
|
|
+ let dom = document.getElementById(this.domId);
|
|
|
+ console.log(dom);
|
|
|
+ let vapPlayer = new Vap.default({
|
|
|
+ container: dom,
|
|
|
+ src: giftModule.gift?.video,
|
|
|
+ config: giftModule.gift?.config,
|
|
|
+ width: window.innerWidth,
|
|
|
+ height: window.innerHeight,
|
|
|
+ fps: 30,
|
|
|
+ mute: false,
|
|
|
+ type: 2,
|
|
|
+ loop: false,
|
|
|
+ precache: true,
|
|
|
+ beginPoint: 0,
|
|
|
+ accurate: true,
|
|
|
+ });
|
|
|
+ vapPlayer.play();
|
|
|
+ vapPlayer.on('ended', () => {
|
|
|
+
|
|
|
+ vapPlayer.destroy();
|
|
|
+ vapPlayer = null;
|
|
|
+ console.log('播放结束');
|
|
|
+ this.msgSerrvice.giftLogMap.pop();
|
|
|
+ if(this.msgSerrvice.giftLogMap.length > 0){
|
|
|
+ this.playGift(this.msgSerrvice.giftLogMap.slice(-1)[0]);
|
|
|
+ }else{
|
|
|
+ this.msgSerrvice.isPlayer = false
|
|
|
+ }
|
|
|
+ });
|
|
|
+ vapPlayer.on('playering', function() { console.log('playering'); })
|
|
|
+ }
|
|
|
ngOnInit() {
|
|
|
}
|
|
|
}
|