This commit is contained in:
gongfuxiang
2025-10-27 18:38:30 +08:00
parent 6e1c1280db
commit 0ac506c77b
4 changed files with 191 additions and 13 deletions

View File

@ -23,7 +23,8 @@
"Geolocation" : {},
"Share" : {},
"VideoPlayer" : {},
"Camera" : {}
"Camera" : {},
"LivePusher" : {}
},
"distribute" : {
"android" : {
@ -186,19 +187,18 @@
}
},
"__usePrivacyCheck__" : true,
"plugins" : {
// 腾讯地图路线规划插件(需要到小程序后台设置->第三方设置->插件管理里面添加【腾讯位置服务路线规划】插件,教程 https://mp.weixin.qq.com/wxopen/plugindevdoc?appid=wx50b5593e81dd937a
// "routePlan" : {
// "version" : "1.0.19",
// "provider" : "wx50b5593e81dd937a"
// },
// 直播(需要到小程序后台设置->第三方设置->插件管理里面添加【小程序直播组件】插件,教程 https://mp.weixin.qq.com/wxopen/pluginbasicprofile?action=intro&appid=wx2b03c6e691cd7370
// "live-player-plugin" : {
// "version" : "1.3.5",
// "provider" : "wx2b03c6e691cd7370"
// }
}
"plugins" : {}
},
// 腾讯地图路线规划插件(需要到小程序后台设置->第三方设置->插件管理里面添加【腾讯位置服务路线规划】插件,教程 https://mp.weixin.qq.com/wxopen/plugindevdoc?appid=wx50b5593e81dd937a
// "routePlan" : {
// "version" : "1.0.19",
// "provider" : "wx50b5593e81dd937a"
// },
// 直播(需要到小程序后台设置->第三方设置->插件管理里面添加【小程序直播组件】插件,教程 https://mp.weixin.qq.com/wxopen/pluginbasicprofile?action=intro&appid=wx2b03c6e691cd7370
// "live-player-plugin" : {
// "version" : "1.3.5",
// "provider" : "wx2b03c6e691cd7370"
// }
"mp-alipay" : {
"usingComponents" : true,
"appid" : "2021001173639600"

View File

@ -2107,6 +2107,39 @@
}
}
]
},
{
"root": "pages/plugins/live",
"pages": [
{
"path": "push/push",
"style": {
// #ifdef MP-WEIXIN || MP-BAIDU || MP-QQ || MP-KUAISHOU || H5 || APP
"navigationStyle": "custom",
// #endif
// #ifdef MP-ALIPAY
"transparentTitle": "auto",
"titlePenetrate": "YES",
// #endif
"enablePullDownRefresh": false,
"navigationBarTitleText": ""
}
},
{
"path": "pull/pull",
"style": {
// #ifdef MP-WEIXIN || MP-BAIDU || MP-QQ || MP-KUAISHOU || H5 || APP
"navigationStyle": "custom",
// #endif
// #ifdef MP-ALIPAY
"transparentTitle": "auto",
"titlePenetrate": "YES",
// #endif
"enablePullDownRefresh": false,
"navigationBarTitleText": ""
}
}
]
}
],
"preloadRule": {

View File

@ -0,0 +1,33 @@
<template>
<view>
<live-player
src="rtmp://live-pull.shopxo.vip/68f764013572f9240ca7ce6c/shopxo"
mode="live"
autoplay
@statechange="statechange"
@error="error"
style="width: 400px; height: 525px;"
/>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
statechange(e){
console.log('live-player code:', e.detail.code)
},
error(e){
console.error('live-player error:', e.detail.errMsg)
}
}
}
</script>
<style>
</style>

View File

@ -0,0 +1,112 @@
<template>
<view>
<live-pusher id='livePusher' ref="livePusher" class="livePusher" url="rtmp://live-push.shopxo.vip/68f764013572f9240ca7ce6c/shopxo"
mode="SD" :muted="true" :enable-camera="true" :auto-focus="true" :beauty="1" whiteness="2"
aspect="9:16" @statechange="statechange" @netstatus="netstatus" @error = "error"
></live-pusher>
<view class="margin-top-xxxxl padding-top-xxxxl">
<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">开启摄像头预览</button>
<button class="btn" @click="stopPreview">关闭摄像头预览</button>
<button class="btn" @click="switchCamera">切换摄像头</button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
context: null
}
},
onReady() {
// 注意需要在onReady中 或 onLoad 延时
var self = this;
setTimeout(function() {
self.context = uni.createLivePusherContext("livePusher", self);
}, 2000);
},
methods: {
statechange(e) {
console.log("statechange:" + JSON.stringify(e));
},
netstatus(e) {
console.log("netstatus:" + JSON.stringify(e));
},
error(e) {
console.log("error:" + JSON.stringify(e));
},
start: function() {
console.log(this.context)
this.context.start({
success: (a) => {
console.log("livePusher.start:" + JSON.stringify(a));
}
});
},
close: function() {
this.context.close({
success: (a) => {
console.log("livePusher.close:" + JSON.stringify(a));
}
});
},
snapshot: function() {
this.context.snapshot({
success: (e) => {
console.log(JSON.stringify(e));
}
});
},
resume: function() {
this.context.resume({
success: (a) => {
console.log("livePusher.resume:" + JSON.stringify(a));
}
});
},
pause: function() {
this.context.pause({
success: (a) => {
console.log("livePusher.pause:" + JSON.stringify(a));
}
});
},
stop: function() {
this.context.stop({
success: (a) => {
console.log(JSON.stringify(a));
}
});
},
switchCamera: function() {
this.context.switchCamera({
success: (a) => {
console.log("livePusher.switchCamera:" + JSON.stringify(a));
}
});
},
startPreview: function() {
this.context.startPreview({
success: (a) => {
console.log("livePusher.startPreview:" + JSON.stringify(a));
}
});
},
stopPreview: function() {
this.context.stopPreview({
success: (a) => {
console.log("livePusher.stopPreview:" + JSON.stringify(a));
}
});
}
}
}
</script>
<style>
</style>