liuxiaolong
2019-05-06 3e0536f508aad49f743e7bfabca34e3980a1b6e2
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>
  <div id="vxgPlayer"></div>
</div>
</template>
<script>
export default {
  props: {
    url: {
      default: '',
      type: String
    },
    width: {
      default: '460',
      type: String
    },
    height: {
      default: '320',
      type: String
    }
  },
  data() {
    return {
 
    }
  },
  methods: {
    /* eslint-disable */
    VxgInit() {
      let node = document.getElementById('vxg_media_player')
      if(!node){
        var playerId = 'vxg_media_player'
        var div = document.createElement('div')
        div.setAttribute('id', playerId)
        div.setAttribute('class', 'vxgplayer')
        var runtimePlayers = document.getElementById('vxgPlayer')
        runtimePlayers.appendChild(div)
        console.log(runtimePlayers, 'vxgplayer')
        vxgplayer(playerId, {
          url: this.url,
          nmf_path: 'media_player.nmf',
          nmf_src: '/static/vxgplayer-1.8.31/pnacl/Release/media_player.nmf',
          latency: 300000,
          width: this.width,
          height: this.height,
          aspect_ratio_mode: 1,
          autohide: 3,
          controls: true,
          connection_timeout: 5000,
          connection_udp: 0,
          custom_digital_zoom: false
        }).ready(function() {
          console.log(' =>ready player ' + this.url)
          vxgplayer(playerId).play()
          console.log(' <=ready player ' + playerId)
        })
      } else {
        node.parentNode.removeChild(node)
        setTimeout(() => {
          var playerId = 'vxg_media_player'
          var div = document.createElement('div')
          div.setAttribute('id', playerId)
          div.setAttribute('class', 'vxgplayer')
          var runtimePlayers = document.getElementById('vxgPlayer')
          runtimePlayers.appendChild(div)
          console.log(runtimePlayers, 'vxgplayer')
          vxgplayer(playerId, {
            url: this.url,
            nmf_path: 'media_player.nmf',
            nmf_src: '/static/vxgplayer-1.8.31/pnacl/Release/media_player.nmf',
            latency: 300000,
            width: this.width,
            height: this.height,
            aspect_ratio_mode: 1,
            autohide: 3,
            controls: true,
            connection_timeout: 5000,
            connection_udp: 0,
            custom_digital_zoom: false
          }).ready(function() {
            console.log(' =>ready player ' + this.url)
            vxgplayer(playerId).play()
            console.log(' <=ready player ' + playerId)
          })
        }, 200)
      }
      
    }
  },
  mounted() {
    let node = document.getElementById('vxg_media_player')
    // node.parentNode.removeChild(node)
    console.log(node,'node')
    // setTimeout(() => {
    //   this.VxgInit()
    // }, 200)
  },
  created() {
    // setTimeout(() => {
    //   this.VxgInit()
    // }, 100)
  }
}
</script>
<style>
</style>