当前位置:网站首页>[play with Tencent cloud] & lt; trtc-room> Applet component usage
[play with Tencent cloud] & lt; trtc-room> Applet component usage
2022-06-24 16:37:00 【sskingss】
< trtc-room > It is a multi terminal real-time audio and video processing scheme launched by Tencent , Official address Introduction . Here are some personal experiences of using this component . use TRTC after , Interworking at each end , You can even use small programs , stay QQ Communicate with wechat , On the web side ,pc Both ends have good support (Electron Also have , Front end Gospel ). add TIM Instant messaging capabilities , You can directly build an enterprise level live broadcast application , If you add Tencent whiteboard , Directly become a small helper in the meeting , Teaching killer , Business scenarios can be freely combined on real-time audio and video services .
Get the code
Can be in github Download the latest code , You can also download the code package directly on the official website , Two addresses are posted here github Tencent cloud official website Code clone Come down or decompress it , Will see trtc-room Code package of a component of , If you just want to access it quickly , Can directly Get through the official website demo, Pay attention to opening up here live-pusher and live-player Authority , The official applet requires separate authorization for these two components .
Code Introduction
pages
- index Index pages of three scene portals
- meeting Multiplayer meeting setup page
- room Multiplayer meeting page
- videocall Two person conversation
- voice-room Speech room
The above is a picture of the app on Tencent's official website ,demo There are three scenarios , Speech room , Two person conversation , A meeting of many people , In this meeting scenario , There are still a lot of places to set ,live-pusher and live-player There are many other properties that can be set . Just to mention here , The page Jump in the component is used uniformly navigateTo, If you use redirectTo Page Jump , Android return key , A false phenomenon that may cause the applet to hang , Here, the recovery time of the page depends on the memory recovery mechanism of the wechat applet , It is not recommended to have live-pusher or live-player The page is placed at the top of the page stack . in addition , For the problem that the applet hangs , Wechat is already launching official solutions , You can always follow the latest developments .
Components trtc-room
- common Inside is the event that the component provides to the outside , Including local and remote default States, etc , There will be detailed notes in this
- user-controller Here is the communication member management module , There are remote members ( downstream ) Management module , It will handle the events thrown by wechat . Here is a brief introduction to the events ,1031 Notification of entry of remote member , 1032 Remote member check out notification , 1033 Notification of remote user video status bit change ( close / Opening and closing ), 1034 Notification of remote user audio status bit change .
- model It defines the local flow (pusher), Distal flow (stream), And the user (user) The basic data structure , One user Maybe there are two stream Of , because pc End or web After screen sharing is enabled, the client will share the same userId Of
- template It contains three templates , Namely 1v1,custom,grid, You can choose according to your type ,custom It can be directly through API To set the display position , I don't think it is in line with the development habits of the front end ,1v1 Call mode , and grid The conference mode of can be directly modified .
Components use
- Sign up for Tencent cloud account . Is to register a good account SDKAppid and SECRETKEY Fill in .
2、 Enter the room after filling in the corresponding data
this.setData({
trtcConfig:{
sdkAppID: '1401000123', // Open the real-time audio and video service and allocate the data after creating the application SDKAppID
userID: 'test_user_001', // user ID, It can be specified by your account system
userSig: 'xxxxxxxxxxxx', // Identity signature , Equivalent to the role of login password
template: 'grid', // Screen layout mode
}
} // Publish local audio and video streams
trtcRoomContext.publishLocalVideo()
trtcRoomContext.publishLocalAudio()
// Listen for the change event of the video stream of the remote user
trtcRoomContext.on(EVENT.REMOTE_VIDEO_ADD, (event)=>{
// subscribe ( Play now ) Remote user's video stream
let userID = event.data.userID
let streamType = event.data.streamType// 'main' or 'aux'
trtcRoomContext.subscribeRemoteVideo({userID: userID, streamType: streamType})
})
// Listen for the change event of the audio stream of the remote user
trtcRoomContext.on(EVENT.REMOTE_AUDIO_ADD, (event)=>{
// subscribe ( Play now ) Remote user's audio stream
let userID = event.data.userID
trtcRoomContext.subscribeRemoteAudio(userID)
})
// get into the room
trtcRoomContext.enterRoom({roomID: 1002}).catch((res)=>{
console.error('room joinRoom Failed to enter the house :', res)
})3、 Disable remote audio and video streaming
unsubscribeRemoteVideo(params) unsubscribeRemoteAudio(params)
4、 Turn off local audio and video
unpublishLocalVideo() unpublishLocalAudio()
5、 Check out
exitRoom()
边栏推荐
- What is the difference between get and post? After reading it, you won't be confused and forced, and you won't have to fight with your friends anymore
- 2021 devopsdays Tokyo Station ends perfectly | coding experts are invited to share the latest technical information
- Saying "Dharma" Today: the little "secret" of paramter and localparam
- [play with Tencent cloud] my operation strategy from domain name application to website filing in Tencent cloud
- The mystery of redis data migration capacity
- Problems encountered in the work of product manager
- 炒期货在哪里开户最正规安全?怎么期货开户?
- Kubernetes popular series: getting started with container Foundation
- If only 2 people are recruited, can the enterprise do a good job in content risk control?
- Page scrolling effect library, a little skinny
猜你喜欢

Problems encountered in the work of product manager

Applet wxss

C. Three displays codeforces round 485 (Div. 2)
MySQL Advanced Series: locks - locks in InnoDB
![[go] concurrent programming channel](/img/6a/d62678467bbc6dfb6a50ae42bacc96.jpg)
[go] concurrent programming channel

Some adventurer hybrid versions with potential safety hazards will be recalled

C. K-th Not Divisible by n(数学+思维) Codeforces Round #640 (Div. 4)

B. Ternary Sequence(思维+贪心)Codeforces Round #665 (Div. 2)

Ui- first lesson

B. Terry sequence (thinking + greed) codeforces round 665 (Div. 2)
随机推荐
Script design for automatic login and command return
Global and Chinese markets of Leyte coin exchange 2022-2028: Research Report on technology, participants, trends, market size and share
50 growers | closed door meeting of marketing circle of friends ス gathering Magic City thinking collision to help enterprise marketing growth
Percona Toolkit series - Pt deadlock logger
ThinkPHP 漏洞利用工具
Clickhouse high performance column storage core principle
Cloud + community [play with Tencent cloud] video solicitation activity winners announced
C. K-th Not Divisible by n(数学+思维) Codeforces Round #640 (Div. 4)
2021 devopsdays Tokyo Station ends perfectly | coding experts are invited to share the latest technical information
Pytorch transpose convolution
How does easydss, an online classroom / online medical live on demand platform, separate audio and video data?
MySQL Innodb和Myisam
C. K-th not divisible by n (Mathematics + thinking) codeforces round 640 (Div. 4)
【prometheus】1. Monitoring overview
Fastjson 漏洞利用技巧
Summer Challenge harmonyos - to do list with date effect
炒期货在哪里开户最正规安全?怎么期货开户?
[play with Tencent cloud] my operation strategy from domain name application to website filing in Tencent cloud
[tke] analysis of CLB loopback in Intranet under IPVS forwarding mode
转置卷积详解