Summary and solutions of audio and video problems in small program development

Table of contents

Question 1: For the development of audio and video, the two small program components live-player and live-pusher are necessary. What are they used for and how can they be used?

Question 2: Only one page can be inserted

Question 3: There is no response to the real machine debugging picture preview and full-screen video

Question 4: Try the version, click the development and debugging to use it normally, close the development and debugging prompt: request:fail url not in domain list

The recently developed audio and video applet is online. Let me summarize the pitfalls stepped on during development, testing, and release, as well as some problems encountered and solutions. I hope it can be helpful to everyone.

Question 1: For the development of audio and video, the two small program components live-player and live-pusher are necessary. What are they used for and how can they be used?

1. Apply for permission to use tags

At present, these two components are only open to the following categories of small programs of domestic entities. They need to pass the category review first, and then activate the component by themselves in the background of the small program management, "Development" - "Development Management" - "Interface Settings" permission.

2. My personal understanding is this: the live-pusher component is used for rendering after the camera is turned on locally, and the live-player is used for rendering when subscribing to the other party’s video stream

For specific usage, please refer to the official document, live-player | WeChat open document   , live-pusher | WeChat open document

Question 2: Only one <live-pusher/> can be inserted into a page

Because the current development needs need a function of switching between large and small screens, two <live-pusher/> components wx:if are used to judge rendering on one page, and the above error is reported, and the large screen display screen is normal when the camera is turned on on my mobile phone It shows that when other people subscribe to my video stream, it is normal to view, but when I switch to the small screen display, the other party sees the picture is still, I switch to the large screen mode again, and the other party sees the normal picture , ( two live-pushers a and b, initialized in a, unable to push stream after switching to b, and resume pushing stream after switching back to a. ) Wechat open community mentioned similar problems, but did not see two live-pushers /> component solutions

Solution;

The current method used is to use a <live-pusher/> component on a page to position and adjust the css according to the position and size. A <live-pusher/> component does not have the above problems

Question 3: There is no response to the real machine debugging picture preview and full-screen video

When using WeChat development tools to develop, wx.previewImage is used normally, but there is no response when debugging on the real machine

Solution; 

1. Change a smaller picture to test, the small program has a limit on the size of the picture

2. If there is no problem with the code, you can test it in the trial version, and it is fine

Question 4: Try the version, click the development and debugging to use normally, close the development and debugging prompt: request:fail url not in domain list

solution: 

1. Make sure that the server domain name and business domain name you use are registered https domain names. The corresponding server domain name and business domain name have been configured in the background of the applet management. If the configuration is omitted or the configuration is incorrect, it will cause the above error.

2. The TLS version is too low to cause this problem, the best version is above 1.2

3. Cache problem, delete all the applets that have been debugged and experienced on the phone and try again.

Because when we usually use WeChat developer tools for development, we sometimes check the local settings to not verify legal domain names, web-view, TLS and HTTPS certificates for the convenience of development. There is no problem if you are developing or debugging on the real machine. If you don’t check it, the problem will also be reproduced in the development environment and real machine debugging. The experience version and the official applet only support https on the domain name (wx.request, wx.uploadFile, wx.downloadFile) and wss (wx.connectSocket) protocols; and the business domain name of https,

Notes on server domain name configuration: Network | WeChat Open Documentation

  • The domain name only supports  https ( wx.request , wx.uploadFile , wx.downloadFile ) and  wss ( wx.connectSocket ) protocols;
  • The domain name cannot use IP address (except the LAN IP of the applet  ) or localhost;
  • You can configure the port, such as https://myserver.com:8080, but after configuration, you can only initiate a request to https://myserver.com:8080. Requests to URLs such as https://myserver.com, https://myserver.com:9091, etc. will fail.
  • If no port is configured. Such as https://myserver.com, then the port cannot be included in the requested URL, even the default port 443 is not allowed. A request to https://myserver.com:443 will fail.
  • The domain name must go through the ICP record;
  • For security reasons, api.weixin.qq.com it cannot be configured as a server domain name, and related APIs cannot be called in Mini Programs. The developer should save the AppSecret in the background server,  getAccessToken obtain it through the server interface  access_token, and call the relevant API;
  • It is not supported to configure the parent domain name and use the subdomain name.

Precautions for business domain name configuration: business domain name | WeChat open document

Guess you like

Origin blog.csdn.net/qq_35432904/article/details/128127678