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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
| <template>
| <div>
| <div class="vxgplayer"
| :id="vxgPlayerId"
| :width="width"
| :height="height"
| :url="url"
| nmf-src="/static/vxgplayer-1.8.31/pnacl/Release/media_player.nmf"
| nmf-path="media_player.nmf"
| useragent-prefix="MMP/3.0"
| latency="10000"
| autohide="2"
| volume="0.7"
| avsync
| controls
| :autostart="true"
| mute
| aspect-ratio
| aspect-ratio-mode="1"
| auto-reconnect
| connection-timeout="5000"
| connection-udp="0"
| custom-digital-zoom>
| </div>
| </div>
| </template>
| <script>
| export default {
| props: {
| url: {
| default: '',
| type: String
| },
| width: {
| default: '460',
| type: String
| },
| height: {
| default: '320',
| type: String
| }
| },
| data() {
| return {
| /** 播放器id */
| playerId: 'vxg_media_player1',
| vxgPlayerId: 'vxgPlayerId',
| videoUrl: ''
| }
| },
| methods: {
| /* eslint-disable */
| vxgplayerInit(optJson) {
| const {
| id = 'vxgplayer',
| url = '',
| nmf_path = 'media_player.nmf',
| nmf_src = '/static/vxgplayer-1.8.31/pnacl/Release/media_player.nmf',
| latency = '10000',
| width = '360px',
| height = '200px',
| aspect_ratio_mode = 1,
| autohide = 3,
| controls = true,
| connection_timeout = 5000,
| connection_udp = 0,
| custom_digital_zoom = false,
| autostart = false
| } = optJson
| vxgplayer(id, {
| ...optJson,
| url: url,
| nmf_path,
| nmf_src,
| latency,
| width,
| height,
| aspect_ratio_mode,
| autohide,
| controls,
| connection_timeout,
| connection_udp,
| custom_digital_zoom
| }).ready(function(data) {
| vxgplayer(id).src(url)
| vxgplayer(id).play()
| // console.log('fn&&fn',vxgplayer(id).isPlaying())
| /* 播放钩子函数 */
| vxgplayer(id).onStateChange(function(state) {
| switch (state) {
| case 0:
| // PLAYER_STOPPED
| break
| case 1:
| // PLAYER_CONNECTING
| break
| case 2:
| // PLAYER_PLAYING 成功播放
| break
| case 3:
| // PLAYER_STOPPING
| break
| default:
| // no ready
| }
| console.log('state', state)
| })
| vxgplayer(id).onError(function(player) {
| console.log(player.error(), '播放错误')
| })
| })
| },
| vxgplayerInit() {
| /* eslint-disable */
| // this.playerId = 'vxg_media_player1' + new Date().getTime() + ''
| // console.log(this.url, ' vxgplayer')
| // var player = vxgplayer(this.playerId)
| // console.log(player, 'player')
| // player.play()
| this.videoUrl ='rtsp://admin:a1234567@192.168.1.64:554/h264/ch1/main/av_stream'
| this.vxgPlayerId = this.vxgPlayerId + new Date().getTime() + ''
| this.$nextTick(() => {
| this.vxgplayerInit({
| id: this.vxgPlayerId,
| url: this.videoUrl,
| autostart: true
| })
| })
| }
| },
| mounted() {
| this.vxgplayerInit()
| },
| watch: {
| refresh(newVal, oldVal) {
| this.vxgplayerInit()
| console.log(newVal, 'refresh----')
| },
| url(newVal, oldVal) {
| this.vxgplayerInit()
| console.log(newVal, 'url----')
| }
| }
| }
| </script>
| <style>
| </style>
|
|