|
@@ -11,6 +11,8 @@ import {
|
|
|
} from '../../../modules/ionic-standalone.modules';
|
|
|
import { AccountService } from '../../../services/account.service';
|
|
|
import { MessageService } from '../../../services/message.service';
|
|
|
+// import Vap from 'video-animation-player'
|
|
|
+declare const Vap: any;
|
|
|
@Component({
|
|
|
selector: 'app-gift-modal',
|
|
|
templateUrl: './gift-modal.component.html',
|
|
@@ -52,10 +54,11 @@ export class GiftModalComponent implements OnInit {
|
|
|
private loadingCtrl: LoadingController,
|
|
|
public accServ: AccountService,
|
|
|
public msgSerrvice: MessageService
|
|
|
- ) {}
|
|
|
-
|
|
|
+ ) {
|
|
|
+ }
|
|
|
async ngOnInit() {
|
|
|
- this.giftList = this.msgSerrvice.giftList
|
|
|
+ this.giftList = this.msgSerrvice.giftList;
|
|
|
+ // this.initPlayer()
|
|
|
}
|
|
|
async openModal() {
|
|
|
let uid: any = Parse.User.current()?.id;
|
|
@@ -102,13 +105,14 @@ export class GiftModalComponent implements OnInit {
|
|
|
loading.dismiss();
|
|
|
_this.sendEmit.emit(); //触发父组件的sendEmit事件
|
|
|
_this.isOpenGift = false;
|
|
|
- _this.isShowGiftModal = true;
|
|
|
+ // _this.isShowGiftModal = true;
|
|
|
_this.publishGiftMessage(_this.currentGift.id, _this.giftCount);
|
|
|
- setTimeout(() => {
|
|
|
- _this.isShowGiftModal = false;
|
|
|
- console.log(_this.isShowGiftModal);
|
|
|
- console.log('5s后关闭');
|
|
|
- }, 5000);
|
|
|
+ // setTimeout(() => {
|
|
|
+ // _this.isShowGiftModal = false;
|
|
|
+ // console.log(_this.isShowGiftModal);
|
|
|
+ // console.log('5s后关闭');
|
|
|
+ // }, 5000);
|
|
|
+ this.initPlayer()
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
_this.isOpenGift = false;
|
|
@@ -121,15 +125,48 @@ export class GiftModalComponent implements OnInit {
|
|
|
});
|
|
|
await alert.present();
|
|
|
}
|
|
|
- onCloseGiftModal(){
|
|
|
- if(!this.isShowGiftModal) this.isShowGiftModal = false
|
|
|
+
|
|
|
+
|
|
|
+ initPlayer(){
|
|
|
+ let json = this.currentGift.config
|
|
|
+ // json = {"info":{"v":2,"f":56,"w":750,"h":1334,"fps":15,"videoW":1136,"videoH":1344,"aFrame":[754,0,375,667],"rgbFrame":[0,0,750,1334],"isVapx":0,"orien":0}}
|
|
|
+ let dom = document.getElementById('vap-warp');
|
|
|
+ let vapPlayer = new Vap.default({
|
|
|
+ container: dom, // 要渲染的载体,dom元素
|
|
|
+ src: this.currentGift.video, // vap动画地址
|
|
|
+ config: json, // 播放vap动画需要的 json文件。必填
|
|
|
+ width: window.innerWidth, // 容器宽度
|
|
|
+ height: window.innerHeight, // 容器高度
|
|
|
+ fps: 30, // 帧数,json文件中有这个视频的帧数的,可以看一下,
|
|
|
+ mute: true, // 静音
|
|
|
+ type: 2, // 组件基于type字段做了实例化缓存,不同的VAP实例应该使用不同的type值(如0、1、2等)
|
|
|
+ loop: false, // 循环
|
|
|
+ precache: true, // 预加载视频,下载完再播。小动画建议边下边播,大动画还是先下后播吧,因为太大了或者网络不好,会一卡一卡的。
|
|
|
+ beginPoint: 0, // 起始播放时间点(单位秒),在一些浏览器中可能无效
|
|
|
+ accurate: true, // 是否启用精准模式(使用requestVideoFrameCallback提升融合效果,浏览器不兼容时自动降级)
|
|
|
+ });
|
|
|
+ vapPlayer.play(); // 开始播放
|
|
|
+ vapPlayer.on('ended', () => {
|
|
|
+ // 监听播放完成的事件
|
|
|
+ vapPlayer.destroy();
|
|
|
+ vapPlayer = null;
|
|
|
+ console.log(123);
|
|
|
+ });
|
|
|
+ vapPlayer.on('playering', function() { console.log('playering'); })
|
|
|
+ }
|
|
|
+
|
|
|
+ onCloseGiftModal() {
|
|
|
+ if (!this.isShowGiftModal) this.isShowGiftModal = false;
|
|
|
}
|
|
|
|
|
|
- publishGiftMessage(gid:string,count:number) {
|
|
|
+ publishGiftMessage(gid: string, count: number) {
|
|
|
this.msgSerrvice.subscribeMessage(this.toUid, {
|
|
|
message: true,
|
|
|
presence: true,
|
|
|
- }); //进入对方主播频道发送聊天邀请
|
|
|
- this.msgSerrvice.publishMessage(`ONUSERSENDGIFT_${gid}_${count}`,this.toUid);
|
|
|
+ }); //触发礼物消息
|
|
|
+ this.msgSerrvice.publishMessage(
|
|
|
+ `ONUSERSENDGIFT_${gid}_${count}`,
|
|
|
+ this.toUid
|
|
|
+ );
|
|
|
}
|
|
|
}
|