|
@@ -7,6 +7,8 @@ import { Subject } from 'rxjs';
|
|
|
import { Router } from '@angular/router';
|
|
|
import { AiChatService } from './aichart.service';
|
|
|
declare const AgoraRTM: any;
|
|
|
+declare const Vap: any;
|
|
|
+
|
|
|
@Injectable({
|
|
|
providedIn: 'root',
|
|
|
})
|
|
@@ -30,6 +32,7 @@ export class MessageService {
|
|
|
giftLogMap: any = [];
|
|
|
giftList: Array<any> = [];
|
|
|
timeg: any;
|
|
|
+ isPlayer:boolean = false;
|
|
|
|
|
|
reset() {
|
|
|
this.options = { connectState: false };
|
|
@@ -152,13 +155,17 @@ export class MessageService {
|
|
|
let toast;
|
|
|
if (message.indexOf('ONUSERSENDGIFT_') > -1) {
|
|
|
let arr = message.split('_');
|
|
|
- let gift = this.giftList.find((item: any) => item.id == arr[1]);
|
|
|
+
|
|
|
+ let r = await this.aiServ.getGift(undefined,arr[1])
|
|
|
+ let gift = r[0]
|
|
|
this.giftLogMap.push({
|
|
|
gift,
|
|
|
count: arr?.[2],
|
|
|
user: userData,
|
|
|
});
|
|
|
- !this.timeg && this.showGiftDecrement();
|
|
|
+ !this.isPlayer && setTimeout(() => {
|
|
|
+ this.playGift(this.giftLogMap.slice(-1)[0]);
|
|
|
+ }, 0);
|
|
|
return;
|
|
|
}
|
|
|
if (message.indexOf('USERGREETING_') > -1) {
|
|
@@ -251,16 +258,51 @@ export class MessageService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- showGiftDecrement() {
|
|
|
- this.timeg = setTimeout(() => {
|
|
|
- this.giftLogMap.shift();
|
|
|
- if (this.giftLogMap.length > 0) {
|
|
|
- this.showGiftDecrement();
|
|
|
- } else {
|
|
|
- clearTimeout(this.timeg);
|
|
|
- this.timeg = null;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ playGift(giftModule:any){
|
|
|
+ console.log(giftModule);
|
|
|
+ this.isPlayer = true
|
|
|
+
|
|
|
+ let dom = document.getElementById('vap-gift');
|
|
|
+ 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.giftLogMap.pop();
|
|
|
+ if(this.giftLogMap.length > 0){
|
|
|
+ this.playGift(this.giftLogMap.slice(-1)[0]);
|
|
|
+ }else{
|
|
|
+ this.isPlayer = false
|
|
|
}
|
|
|
- }, 5000);
|
|
|
+ });
|
|
|
+ vapPlayer.on('playering', function() { console.log('playering'); })
|
|
|
}
|
|
|
|
|
|
async getRoom(uid: string): Promise<string | undefined> {
|