fix: bug
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
import request from '@/api/request'
|
||||
|
||||
export const prepareApi = (name) => {
|
||||
return request({
|
||||
url: '/trapractice/audio/session/prepare?name=' + name,
|
||||
method: 'post',
|
||||
toastErrors: true,
|
||||
baseUrl: 'http://25.64.32.157:9603'
|
||||
});
|
||||
};
|
||||
@@ -14,7 +14,7 @@
|
||||
<view class="body-top-title">
|
||||
{{ detailInfo.traName }}
|
||||
</view>
|
||||
<view class="body-top-item"> 已练习次数:{{ detailInfo.practiceTimes }} </view>
|
||||
<view class="body-top-item"> 已陪练次数:{{ detailInfo.practiceTimes }} </view>
|
||||
<view class="body-top-item"> 类型:{{ detailInfo.traInterTypDesc }} </view>
|
||||
<view class="body-top-item"> 截止时间:{{detailInfo.limitTyp === '01' ? '不限制' : detailInfo.endTm}}</view>
|
||||
<scroll-view class="body-top-tags" :scroll-x="true">
|
||||
|
||||
@@ -298,6 +298,7 @@
|
||||
triggered.value = true
|
||||
refresherEnabled.value = false
|
||||
sparringListBase.value = []
|
||||
currentTabSec.value = 0
|
||||
activeTab.value = item.name
|
||||
activeTabId.value = item.value || ''
|
||||
activeLeftIndex.value = -1
|
||||
@@ -366,6 +367,7 @@
|
||||
}
|
||||
const reSeting = ref(false)
|
||||
onMounted(() => {
|
||||
console.log('onMounted')
|
||||
reSeting.value = true
|
||||
setTimeout(() => {
|
||||
reSeting.value = false
|
||||
@@ -395,6 +397,7 @@
|
||||
uni.$off('refresh_sparring_list')
|
||||
})
|
||||
onActivated(() => {
|
||||
console.log('onActivated')
|
||||
reSeting.value = true
|
||||
setTimeout(() => {
|
||||
reSeting.value = false
|
||||
@@ -413,6 +416,9 @@
|
||||
})
|
||||
})
|
||||
onShow(() => {
|
||||
console.log('onShow')
|
||||
activeTag.value = []
|
||||
getMoreList(1)
|
||||
socketStore.closeSocket()
|
||||
uni.$on('refresh_sparring_list', () => {
|
||||
changeTab({
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
|
||||
<template>
|
||||
<view>
|
||||
<video :is-live="true" :src="videoSrc" :autoplay="true" @error="error"></video>
|
||||
<view id="pusher-box"></view>
|
||||
<button class="btn" @click="start">开始推流</button>
|
||||
<button class="btn" @click="pause">暂停推流</button>
|
||||
<button class="btn" @click="resume">预热</button>
|
||||
<button class="btn" @click="stop">停止推流</button>
|
||||
<button class="btn" @click="snapshot">快照</button>
|
||||
<button class="btn" @click="startPreview">开启摄像头预览1</button>
|
||||
<button class="btn" @click="stopPreview">关闭摄像头预览</button>
|
||||
<button class="btn" @click="switchCamera">切换摄像头</button>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import { prepareApi } from "@/api/talk.js"
|
||||
var pusher;
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
baseName: 'zhangsan',
|
||||
context: null
|
||||
}
|
||||
},
|
||||
computed:{
|
||||
videoSrc(){
|
||||
return 'rtmp://25.18.122.148:9605/voice_out/' + this.baseName
|
||||
},
|
||||
},
|
||||
onReady() {
|
||||
},
|
||||
methods: {
|
||||
statechange(e) {
|
||||
console.log('statechange:', e, JSON.stringify(e))
|
||||
},
|
||||
netstatus(e) {
|
||||
console.log('netstatus:' + JSON.stringify(e))
|
||||
},
|
||||
error(e) {
|
||||
console.log('error:' + JSON.stringify(e))
|
||||
},
|
||||
start: function () {
|
||||
console.log('start')
|
||||
console.log('start',pusher.start)
|
||||
pusher.start(a => {
|
||||
console.log('livePusher.start:')
|
||||
},b=>{
|
||||
console.log('livePusher.start.err:' )
|
||||
})
|
||||
},
|
||||
close: function () {
|
||||
pusher.close({
|
||||
success: a => {
|
||||
console.log('livePusher.close:' + JSON.stringify(a))
|
||||
}
|
||||
})
|
||||
},
|
||||
snapshot: function () {
|
||||
pusher.snapshot({
|
||||
success: e => {
|
||||
console.log(JSON.stringify(e))
|
||||
}
|
||||
})
|
||||
},
|
||||
resume: function () {
|
||||
prepareApi(this.baseName).then(res=>{
|
||||
console.log(res)
|
||||
}).catch(err=>{
|
||||
console.log(err)
|
||||
if(err === 'prepare'){
|
||||
this.initPusher()
|
||||
}
|
||||
})
|
||||
},
|
||||
pause: function () {
|
||||
pusher.pause({
|
||||
success: a => {
|
||||
console.log('livePusher.pause:' + JSON.stringify(a))
|
||||
}
|
||||
})
|
||||
},
|
||||
stop: function () {
|
||||
pusher.stop({
|
||||
success: a => {
|
||||
console.log(JSON.stringify(a))
|
||||
}
|
||||
})
|
||||
},
|
||||
switchCamera: function () {
|
||||
pusher.switchCamera({
|
||||
success: a => {
|
||||
console.log('livePusher.switchCamera:' + JSON.stringify(a))
|
||||
}
|
||||
})
|
||||
},
|
||||
startPreview: function () {
|
||||
pusher.startPreview({
|
||||
success: a => {
|
||||
console.log('livePusher.startPreview:' + JSON.stringify(a))
|
||||
}
|
||||
})
|
||||
},
|
||||
stopPreview: function () {
|
||||
pusher.stopPreview({
|
||||
success: a => {
|
||||
console.log('livePusher.stopPreview:' + JSON.stringify(a))
|
||||
}
|
||||
})
|
||||
},
|
||||
initPusher(){
|
||||
console.log(1)
|
||||
pusher = new plus.video.LivePusher('pusher-box',{
|
||||
url: 'rtmp://25.18.122.148:9605/voice_in/' + this.baseName,
|
||||
"enable-camera": false
|
||||
})
|
||||
pusher.addEventListener('statechange', this.statechange)
|
||||
pusher.addEventListener('netstatus', this.netstatus)
|
||||
pusher.addEventListener('error', this.error)
|
||||
console.log(pusher)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
#pusher-box{
|
||||
width: 100vw;
|
||||
height: 400rpx;
|
||||
}
|
||||
|
||||
</style>
|
||||
+65
-32
@@ -1,37 +1,41 @@
|
||||
<!-- <template>
|
||||
<view>通话</view>
|
||||
<live-pusher
|
||||
url="rtmp://25.18.122.148:9605/voice_in/aa"
|
||||
:enable-camera="true"
|
||||
@statechange="statechange"
|
||||
@netstatus="netstatus"
|
||||
@error="errorFnc"
|
||||
></live-pusher>
|
||||
</template> -->
|
||||
|
||||
<template>
|
||||
<view>
|
||||
<video :is-live="true" :src="videoSrc" :autoplay="true"></video>
|
||||
<video :is-live="true" id="myVideo" :src="videoSrc" :autoplay="true"></video>
|
||||
<live-pusher id="livePusher" ref="livePusher" class="livePusher" url="rtmp://25.18.122.148:9605/voice_in/aa" mode="SD" :muted="true" :enable-camera="false" :auto-focus="true" :beauty="1" whiteness="2" aspect="9:16" @statechange="statechange" @netstatus="netstatus" @error="error"></live-pusher>
|
||||
<button class="btn" @click="start">开始推流</button>
|
||||
<button class="btn" @click="pause">暂停推流</button>
|
||||
<button class="btn" @click="resume">resume</button>
|
||||
<button class="btn" @click="stop">停止推流</button>
|
||||
<button class="btn" @click="snapshot">快照</button>
|
||||
<button class="btn" @click="startPreview">开启摄像头预览1</button>
|
||||
<button class="btn" @click="stopPreview">关闭摄像头预览</button>
|
||||
<button class="btn" @click="switchCamera">切换摄像头</button>
|
||||
|
||||
<view class="btn" @click="prepare"><text>预热</text></view>
|
||||
<view class="btn" @click="start"><text>开始推流</text></view>
|
||||
<view class="btn" @click="pause"><text>暂停推流</text></view>
|
||||
<view class="btn" @click="resume"><text>恢复推流</text></view>
|
||||
<view class="btn" @click="stop"><text>停止推流</text></view>
|
||||
<view class="btn" @click="snapshot"><text>快照</text></view>
|
||||
<view class="btn" @click="startPreview"><text>开启摄像头预览</text></view>
|
||||
<view class="btn" @click="stopPreview"><text>关闭摄像头预览</text></view>
|
||||
<view class="btn" @click="switchCamera"><text>切换摄像头</text></view>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import { prepareApi } from "@/api/talk.js"
|
||||
var pusher
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
videoSrc: 'rtmp://25.18.122.148:9605/voice_out/aa'
|
||||
context:null,
|
||||
baseName: 'zhangsan'
|
||||
}
|
||||
},
|
||||
computed:{
|
||||
videoSrc(){
|
||||
return 'rtmp://25.18.122.148:9605/voice_out/' + this.baseName
|
||||
},
|
||||
},
|
||||
onReady() {
|
||||
const videoContext = uni.createVideoContext('myVideo')
|
||||
videoContext.setVolume(1.0)
|
||||
// 注意:需要在onReady中 或 onLoad 延时
|
||||
this.context = uni.createLivePusherContext('livePusher', this)
|
||||
// pusher = uni.createLivePusherContext('livePusher', this)
|
||||
// console.log(pusher)
|
||||
},
|
||||
methods: {
|
||||
statechange(e) {
|
||||
@@ -44,69 +48,98 @@ export default {
|
||||
console.log('error:' + JSON.stringify(e))
|
||||
},
|
||||
start: function () {
|
||||
this.context.start({
|
||||
console.log('statechange:',pusher.start)
|
||||
pusher.start({
|
||||
success: a => {
|
||||
console.log('livePusher.start:' + JSON.stringify(a))
|
||||
}
|
||||
})
|
||||
},
|
||||
prepare: function () {
|
||||
prepareApi(this.baseName).then(res=>{
|
||||
console.log(res)
|
||||
}).catch(err=>{
|
||||
console.log(err)
|
||||
if(err === 'prepare'){
|
||||
this.initPusher()
|
||||
}
|
||||
})
|
||||
},
|
||||
close: function () {
|
||||
this.context.close({
|
||||
pusher.close({
|
||||
success: a => {
|
||||
console.log('livePusher.close:' + JSON.stringify(a))
|
||||
}
|
||||
})
|
||||
},
|
||||
snapshot: function () {
|
||||
this.context.snapshot({
|
||||
pusher.snapshot({
|
||||
success: e => {
|
||||
console.log(JSON.stringify(e))
|
||||
}
|
||||
})
|
||||
},
|
||||
resume: function () {
|
||||
this.context.resume({
|
||||
pusher.resume({
|
||||
success: a => {
|
||||
console.log('livePusher.resume:' + JSON.stringify(a))
|
||||
}
|
||||
})
|
||||
},
|
||||
pause: function () {
|
||||
this.context.pause({
|
||||
pusher.pause({
|
||||
success: a => {
|
||||
console.log('livePusher.pause:' + JSON.stringify(a))
|
||||
}
|
||||
})
|
||||
},
|
||||
stop: function () {
|
||||
this.context.stop({
|
||||
pusher.stop({
|
||||
success: a => {
|
||||
console.log(JSON.stringify(a))
|
||||
}
|
||||
})
|
||||
},
|
||||
switchCamera: function () {
|
||||
this.context.switchCamera({
|
||||
pusher.switchCamera({
|
||||
success: a => {
|
||||
console.log('livePusher.switchCamera:' + JSON.stringify(a))
|
||||
}
|
||||
})
|
||||
},
|
||||
startPreview: function () {
|
||||
this.context.startPreview({
|
||||
pusher.startPreview({
|
||||
success: a => {
|
||||
console.log('livePusher.startPreview:' + JSON.stringify(a))
|
||||
}
|
||||
})
|
||||
},
|
||||
stopPreview: function () {
|
||||
this.context.stopPreview({
|
||||
pusher.stopPreview({
|
||||
success: a => {
|
||||
console.log('livePusher.stopPreview:' + JSON.stringify(a))
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
initPusher(){
|
||||
console.log(1)
|
||||
pusher = new plus.video.LivePusher('pusher-box',{
|
||||
url: 'rtmp://25.18.122.148:9605/voice_in/' + this.baseName,
|
||||
"enable-camera": false
|
||||
})
|
||||
pusher.addEventListener('statechange', this.statechange)
|
||||
pusher.addEventListener('netstatus', this.netstatus)
|
||||
pusher.addEventListener('error', this.error)
|
||||
console.log(pusher)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style></style>
|
||||
<style>
|
||||
.btn{
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
background-color: #ccc;
|
||||
margin-bottom: 5rpx;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,26 +1,18 @@
|
||||
<!-- <template>
|
||||
<view>通话</view>
|
||||
<live-pusher
|
||||
url="rtmp://25.18.122.148:9605/voice_in/aa"
|
||||
:enable-camera="true"
|
||||
@statechange="statechange"
|
||||
@netstatus="netstatus"
|
||||
@error="errorFnc"
|
||||
></live-pusher>
|
||||
</template> -->
|
||||
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<video :is-live="true" :src="videoSrc" :autoplay="true"></video>
|
||||
<view>
|
||||
<video :is-live="true" :src="videoSrc" :autoplay="true" @error="error"></video>
|
||||
<live-pusher id="livePusher" ref="livePusher" class="livePusher" url="rtmp://25.18.122.148:9605/voice_in/aa" mode="SD" :muted="true" :enable-camera="false" :auto-focus="true" :beauty="1" whiteness="2" aspect="9:16" @statechange="statechange" @netstatus="netstatus" @error="error"></live-pusher>
|
||||
<text class="btn" @click="start">开始推流</text>
|
||||
<text class="btn" @click="pause">暂停推流</text>
|
||||
<text class="btn" @click="resume">resume</text>
|
||||
<text class="btn" @click="stop">停止推流</text>
|
||||
<text class="btn" @click="snapshot">快照</text>
|
||||
<text class="btn" @click="startPreview">开启摄像头预览1</text>
|
||||
<text class="btn" @click="stopPreview">关闭摄像头预览</text>
|
||||
<text class="btn" @click="switchCamera">切换摄像头</text>
|
||||
</div>
|
||||
<button class="btn" @click="start">开始推流</button>
|
||||
<button class="btn" @click="pause">暂停推流</button>
|
||||
<button class="btn" @click="resume">resume</button>
|
||||
<button class="btn" @click="stop">停止推流</button>
|
||||
<button class="btn" @click="snapshot">快照</button>
|
||||
<button class="btn" @click="startPreview">开启摄像头预览1</button>
|
||||
<button class="btn" @click="stopPreview">关闭摄像头预览</button>
|
||||
<button class="btn" @click="switchCamera">切换摄像头</button>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
Reference in New Issue
Block a user