直播sdk

qiuruirong b3e0c17f94 fix:调整接口 il y a 1 an
.hbuilderx 36f7d65e89 no message il y a 1 an
components 06c55d9040 no message il y a 2 ans
node_modules 06c55d9040 no message il y a 2 ans
pages 613e2c6c61 no message il y a 1 an
uni_modules b3e0c17f94 fix:调整接口 il y a 1 an
unpackage 613e2c6c61 no message il y a 1 an
App.vue 06c55d9040 no message il y a 2 ans
README.md 613e2c6c61 no message il y a 1 an
index.html 06c55d9040 no message il y a 2 ans
main.js 06c55d9040 no message il y a 2 ans
manifest.json 01faf3f37c fix:插件模式 il y a 1 an
package-lock.json 06c55d9040 no message il y a 2 ans
package.json 01faf3f37c fix:插件模式 il y a 1 an
pages.json 01faf3f37c fix:插件模式 il y a 1 an
uni.promisify.adaptor.js 06c55d9040 no message il y a 2 ans
uni.scss 06c55d9040 no message il y a 2 ans

README.md

项目初始化

npm init -y
npm install crypto-js --save
npm install hashids --save

项目设置

引入uni_modules包 manifest.json app插件配置腾讯直播插件

直播端接入

<template>
	<view>
		<RY-TencentLive-Pusher class="live" ref="livePusher" v-bind:style="{ width: playerWidth, height: playerHeight,background: '#252e37' }"></RY-TencentLive-Pusher>
		<live-push ref="livePush" @goDetail="goDetail" @buyGoods="buyGoods" @shearRoom="shearRoom">
			<template v-slot:goodsDetail>
				<view  style="width: 100%;height: 300px;background-color: darkcyan;margin-bottom: 10px;border-radius: 20rpx 20rpx 0 0;">
					商品详情
				</view>
			</template>
		</live-push>
	</view>
</template>
import stream from '@/uni_modules/equnphp-streaming/components/equnphp-streaming.js';
export default {
	data() {
		return {
			playerWidth:uni.getSystemInfoSync().windowWidth,
			playerHeight:uni.getSystemInfoSync().windowHeight
		}
	},
	onLoad(option) {
		let self = this 
		this.$nextTick(function() {
			// 直播初始化
			stream.init({
				liveId: option.live_id,
				userId: option.user_id,
				nickName: option.nick_name,
				livePusher: self.$refs.livePusher,
				playerWidth: self.playerWidth,
				playerHeight: self.playerHeight,
				liveType: 'push'
			});
		})
	},
	methods:{
		// 商品详情
		goDetail(data) {
			console.log("商品详情",data)
		},
		// 去抢购
		buyGoods(data) {
			console.log("去抢购",data)
		},
		// 分享
		shearRoom(data){
			console.log("分享",data)
		}
	}
}

播放端接入

<template>
	<view>
		<!-- #ifdef APP-PLUS -->
		<RY-TencentLive-Player class="live" ref="livePlayer" v-bind:style="{ width: playerWidth, height: playerHeight, background: '#252e37' }"></RY-TencentLive-Player>
		<!-- #endif -->
		<live-play ref="livePlay" @goDetail="goDetail" @buyGoods="buyGoods">
			<template v-slot:goodsDetail>
				<view  style="width: 100%;height: 300px;background-color: darkcyan;margin-bottom: 10px;border-radius: 20rpx 20rpx 0 0;">
					商品详情
				</view>
			</template>
		</live-play>
	</view>
</template>
import stream from '@/uni_modules/equnphp-streaming/components/equnphp-streaming.js';
export default {
	data() {
		return {
			playerWidth:uni.getSystemInfoSync().windowWidth,
			playerHeight:uni.getSystemInfoSync().windowHeight
		}
	},
	onLoad(option) {
		let self = this
		this.$nextTick(function() {
			// 直播初始化
			stream.init({
				liveId: option.live_id,
				merId: option.merId,
				userId: option.user_id,
				nickName: option.nick_name,
				livePlayer: self.$refs.livePlayer,
				playerWidth: self.playerWidth,
				playerHeight: self.playerHeight,
				liveType: 'play'
			});
		})
	},
	methods:{
		// 商品详情
		goDetail(data) {
			console.log("商品详情",data)
		},
		// 去抢购
		buyGoods(data) {
			console.log("去抢购",data)
		}
	}
}