0.0.2 • Published 2 years ago

vue-live-talk v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

vue-live-talk

1078 websocket 实时对讲

Demo: https://lin557.github.io/vue-live-talk/demo/

Installation

npm install --save vue-live-talk

Usage

To include vue-live-talk on your website or web application, use any of the following methods.

Fully import

In main.js:

import Vue from 'vue'
import VueLiveTalk from 'vue-live-talk'
Vue.use(VueLiveTalk)

On demand

<template>
  <div>
    <VueLiveTalk
      :sampleRate="16000"
      ref="talk"
    />
  </div>
</template>

<script>
import VueLiveTalk from 'vue-live-talk'

export default {
  components: {
    VueLiveTalk
  },
  data() {
    return {
      imei: '12345',
      chn: 1,
      url: 'ws://localhost:9095/ws/talk',
    }
  },
  methods: {
    talk() {
      this.$refs.talk.talk({
        url: this.url,
        imei: this.imei,
        chn: this.chn
      })
      this.disabled = true
    },
    close() {
      this.disabled = false
      this.$refs.talk.close()
    }
  }
}
</script>

Attributes

PropertyDescriptionTypeDefault
sample_rateSample rate. 8000, 11025, 16000, 22050, 32000, 44100, 48000number8000
locallocalized configurationobject

local object

PropertyDescriptionValue
busyDevice Busy繁忙
cancelcancel忽略
connectingWebsocket connecting连接中
connectedWebsocket connected已连接(等待设备语音)
disconnectedWebsocket disconnected已断开
errorerror错误
errCodecUnsupported audio codec不支持的编码
errCrossCross domain无权录音(跨域)
errHttpsNeed https无权录音(需https)
errSocketWebsocket error连接错误
initinit未启动
kickoutkickout会话冲突
noAllowUser denied recording permission用户拒绝录音权限
noMicNo microphone available无可用麦克风
talkingTalking通话中
timeoutTimeout终端超时

Methods

talk(param)

connect and talk

param = {
  url: "ws://www.demo.com/ws/talk",
  imei: "12345",
  chn: 1
}
PropertyDescriptionTypeDefault
urlws urlstringany
imeiDevice imei/sim numberstringany
chnDevice channel numbernumber1

close()

Close talk

License

MIT. Copyright (c) lin557