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
<template>
  <div>
    <div id="divPlugin" :style="`width:${width};height:${height}`"></div>
  </div>
</template>
<script>
import { WebVideo } from './WebVideo.js'
export default {
  props: {
    json: {
      type: Object,
      default: function() {
        return {
          deviceport: '8000',
          rtspport: '554',
          ip: '192.168.1.215',
          port: '80',
          username: 'admin',
          password: 'a1234567'
        }
      }
    },
    width: {
      type: String,
      default: '550px'
    },
    height: {
      type: String,
      default: '320px'
    }
  },
  data() {
    return {
      webVideo: {}
    }
  },
  methods: {
    Init() {
      console.log('进入初始化插件方法')
      this.webVideo.init()
      this.$nextTick(() => {
        this.LonginPlay()
      })
    },
    /** 登录并播放视频 */
    LonginPlay() {
      this.webVideo.clickLogin()
    }
  },
  mounted() {
    console.log(this.json, 'this.json')
    this.webVideo = new WebVideo(this.json)
    this.$nextTick(() => {
      this.Init()
    })
  },
  watch: {
    json: {
      handler(newVal, oldVal) {
        console.log(oldVal, 'oldVal', newVal)
        if (newVal !== oldVal) {
          this.webVideo = new WebVideo(newVal)
          this.$nextTick(() => {
            this.Init()
          })
        }
      },
      deep: true
    }
  }
}
</script>
<style>
</style>