ceshi.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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" id="cameraTest" allowfullscreen/>
  8. </view>
  9. </template>
  10. <script>
  11. export default {
  12. data() {
  13. return {
  14. id: '',
  15. url: '',
  16. access_token: ''
  17. }
  18. },
  19. onLoad(option) {
  20. this.url = ""
  21. uni.request({
  22. url: 'https://open.hikyun.com/artemis/oauth/token/v2',
  23. method: 'POST',
  24. data: {
  25. accessKey: "16365122785078383",
  26. secretKey: "ctZiCTxLpKLdSKjjKkWa",
  27. productCode: "1636609606025604",
  28. projectId: "1321376925660208"
  29. },
  30. success: (res) => {
  31. console.log(res.data.data);
  32. this.access_token = res.data.data.access_token
  33. // this.url = "https://open.ys7.com/ezopen/h5/iframe?url=ezopen://open.ys7.com/" +
  34. // 'G71540859' + "/" + '1' + ".hd.live&accessToken=" + this.access_token + "&templete=1"
  35. console.log(this.url)
  36. }
  37. });
  38. // this.url = 'rtmp://ns8.indexforce.com/home/mystream'
  39. // this.getUrl(option.id);
  40. // uni.setNavigationBarTitle({
  41. // title:option.title
  42. // })
  43. },
  44. methods: {
  45. getUrl(id) {
  46. var paramA = {
  47. action: 'app/shipinbofang/searchUrl',
  48. noid: id,
  49. actiondesc: '根据监控id生成预览url'
  50. };
  51. this.$request
  52. .post(paramA.action, paramA)
  53. .then(data => {
  54. if (data.success) {
  55. this.url = data.url;
  56. }
  57. })
  58. },
  59. }
  60. }
  61. </script>
  62. <!-- <template>
  63. <view>
  64. <view class="content">
  65. <image class="logo" src="/static/logo.png"></image>
  66. <view class="text-area">
  67. <button type="default" @click="hkPreview">实时视频预览</button>
  68. <button type="default" @click="hkFullPreview">直接全屏预览</button>
  69. </view>
  70. </view>
  71. </view>
  72. </template>
  73. ```javascript
  74. <script>
  75. //导入本地插件
  76. const hk = uni.requireNativePlugin('hk-preview');
  77. export default {
  78. data() {
  79. return {
  80. src:'rtmp://ns8.indexforce.com/home/mystream',
  81. title: 'Hello',
  82. url:'rtmp://live.hkstv.hk.lxdns.com/live/hks1'
  83. }
  84. },
  85. onLoad() {
  86. },
  87. created() {
  88. },
  89. methods: {
  90. hkPreview() {
  91. //有云台设备,显示操作云台菜单
  92. //ip地址,用户名,密码,端口号,通道号
  93. hk.startActivity("http://zijun.qdcandor.com","admin","Zhongdian12#$","80","1")
  94. },
  95. hkFullPreview() {
  96. //无云台设备直接全屏播放
  97. //ip地址,用户名,密码,端口号,通道号
  98. hk.startFullActivity("http://zijun.qdcandor.com","admin","Zhongdian12#$","7101","1")
  99. }
  100. }
  101. }
  102. </script> -->