ceshi.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <!-- <view></view> -->
  3. <!-- <view :style="{width: '100%', height: '100%'}" id="view">
  4. <video id="preview" style=" width: 100%;" autoplay="autoplay" :src="url"></video>
  5. </view> -->
  6. <view>
  7. <iframe :src="url" width="100%" height="400" style="background-color: #000000;" id="cameraTest" allowfullscreen />
  8. <view style="width: 100%;text-align: center;">
  9. <h1>仓库门口</h1>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. data() {
  16. return {
  17. id: '',
  18. url: '',
  19. access_token: ''
  20. }
  21. },
  22. onLoad(option) {
  23. // this.url = ""
  24. uni.request({
  25. url: 'https://open.hikyun.com/artemis/oauth/token/v2',
  26. method: 'POST',
  27. data: {
  28. accessKey: "16365122785078383",
  29. secretKey: "ctZiCTxLpKLdSKjjKkWa",
  30. productCode: "1636609606025604",
  31. projectId: "1321376925660208"
  32. },
  33. success: (res) => {
  34. this.access_token = res.data.data.access_token
  35. uni.request({
  36. url: 'https://open.hikyun.com/artemis/api/eits/v1/global/live/video/preview',
  37. method: 'POST',
  38. header: {
  39. "access_token": res.data.data.access_token,
  40. },
  41. data: {
  42. "toolBar": 0,
  43. "deviceSerial": "G26011245",
  44. "channelNo": 1,
  45. "videoLevel": 1,
  46. "audio": 1,
  47. "autoPlay": 1,
  48. "projectId": 1321376925660208
  49. },
  50. success: (res) => {
  51. console.log(res)
  52. this.url = res.data.data.previewUrl
  53. }
  54. });
  55. }
  56. });
  57. // this.url = 'rtmp://ns8.indexforce.com/home/mystream'
  58. // this.getUrl(option.id);
  59. // uni.setNavigationBarTitle({
  60. // title:option.title
  61. // })
  62. },
  63. methods: {
  64. getUrl(id) {
  65. var paramA = {
  66. action: 'app/shipinbofang/searchUrl',
  67. noid: id,
  68. actiondesc: '根据监控id生成预览url'
  69. };
  70. this.$request
  71. .post(paramA.action, paramA)
  72. .then(data => {
  73. if (data.success) {
  74. this.url = data.url;
  75. }
  76. })
  77. },
  78. }
  79. }
  80. </script>
  81. <!-- <template>
  82. <view>
  83. <view class="content">
  84. <image class="logo" src="/static/logo.png"></image>
  85. <view class="text-area">
  86. <button type="default" @click="hkPreview">实时视频预览</button>
  87. <button type="default" @click="hkFullPreview">直接全屏预览</button>
  88. </view>
  89. </view>
  90. </view>
  91. </template>
  92. ```javascript
  93. <script>
  94. //导入本地插件
  95. const hk = uni.requireNativePlugin('hk-preview');
  96. export default {
  97. data() {
  98. return {
  99. src:'rtmp://ns8.indexforce.com/home/mystream',
  100. title: 'Hello',
  101. url:'rtmp://live.hkstv.hk.lxdns.com/live/hks1'
  102. }
  103. },
  104. onLoad() {
  105. },
  106. created() {
  107. },
  108. methods: {
  109. hkPreview() {
  110. //有云台设备,显示操作云台菜单
  111. //ip地址,用户名,密码,端口号,通道号
  112. hk.startActivity("http://zijun.qdcandor.com","admin","Zhongdian12#$","80","1")
  113. },
  114. hkFullPreview() {
  115. //无云台设备直接全屏播放
  116. //ip地址,用户名,密码,端口号,通道号
  117. hk.startFullActivity("http://zijun.qdcandor.com","admin","Zhongdian12#$","7101","1")
  118. }
  119. }
  120. }
  121. </script> -->