1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
| <template>
| <div class="box">
| <!-- <div :id="id" style="height: 420px;margin:10px 0px;"></div>-->
| <div :id="id" style="height: 280px;margin:10px 0px;"></div>
| </div>
| </template>
| <script>
| export default {
| props: ["url","id"],
| data() {
| return {
| voidHeight: "",
| player: null,
| MyPlayer:""
| // src:"https://c32g3201.ply.univms.univdn.net:10443/10000051/uni0321122030208211775/uni0320031122061404794581.flv?group_id=uni0321122030208211775&v_codec=h264&key=e07c6dd502ee0d112517d419e6ec3dbf&time=1654705820"
| }
| },
| mounted() {
| //this.height ? (this.voidHeight = this.height) : (this.voidHeight = "100%");
|
| // 页面加载完成后,初始化
| this.$nextTick(() => {
|
| if (this.player != null && this.url != "") {
| this.playPlause();
| this.playerClose();
| this.player = null;
| }
| // 实例化播放器
| this.player = new WasmPlayer(null, this.id, this.callbackfun, {
| Height: true
| })
| // 调用播放
| this.player.play(this.url, 1);
| console.log(this.url,'url')
| });
| },
| methods: {
| callbackfun(e) {
| if(e.code==502){
| this.player.destroy(this.url);
| }
| },
|
| //组件暂停
| playPlause() {
| this.player.pause(this.url);
| },
|
| //组件关闭
| playerClose() {
| this.player.destroy(this.url);
| },
|
|
| },
|
| beforeDestroy() {
| if (this.player != null && this.url != "") {
| //this.playPlause();
| this.playerClose();
| openAudio: true; //openAudio:是否打开音频
| BigPlay: false;
| HideKbs: true //HideKbs:是否隐藏实时码率
| }
| },
|
| watch: {
| url: {
| handler(newVal, oldVal) {
| this.url = newVal;
| if (this.player != null && this.url != "") {
| //this.playPlause();
| this.playerClose();
| //this.player=null;
| }
| this.player = new WasmPlayer(null, this.id, this.callbackfun, {
| Height: true
| })
| // 调用播放
| this.player.play(this.url, 1)
| },
| }
|
|
| },
|
|
|
|
|
|
|
|
| }
| </script>
| <style scoped="scoped" lang="less">
| .box {
| width: 100%;
| height: 100%;
|
| #Player {
| height: 540px;
| }
| }
| </style>
|
|