Home > WeChat Applet > Mini Program Development > How to use Tencent video plug-in in mini program

How to use Tencent video plug-in in mini program

angryTom
Release: 2020-03-17 09:25:29
forward
4551 people have browsed it

Video services are required when developing mini program projects. If you use your own server to play it, it will incur a lot of expenses. At this time, we can use the Tencent video plug-in of the mini program and quote Tencent Video in the page.

How to use Tencent video plug-in in mini program

How to use the Tencent video plug-in in a mini program

When developing a mini program project, you need to watch videos on the page , you need to use the Tencent video plug-in of the WeChat applet, so that you can reference Tencent video in the page without using your own server for video playback, saving a lot of server expenses.

Recommended learning: navicat tutorial

When developing a mini program project, if you need to watch videos on the page, you need to use the Tencent video plug-in of the WeChat mini program. In this way, Tencent Video can be referenced in the page without using its own server for video playback, which saves a lot of server expenses. However, the documentation for the WeChat applet plug-in is very unclear, so I will write my solution here.

Introduce plug-ins into the mini program.

Enter the WeChat public platform, find the third-party service in the settings, and add the plug-in in the plug-in management. Search for Tencent Video, click Add, and open the details of Tencent Video, where you will find the appid and version number of the plug-in.

Then comes the code part, add

plugins: {
    tencentVideo: {
      version: 1.1.1,
      provider: wxa75efa648b60994b
    }
Copy after login

in app.json where version is the version number and provider is the appid.

Reference the components of the plug-in in the page that needs to be used

The official document does not have specific instructions on this method, so it will cause the problem that the txv-video corresponding to the playerid cannot be found

Open the json file that you want to use the plug-in page, and add

usingComponents: 
{
txv-video: plugin://tencentVideo/video
}
Copy after login

in it. This means that the txv-video component can be used in the page.

in the page Use component

to enter the wxml file and add

in it. This step is very simple. vid is the vid of Tencent Video and playerid is the unique identification code of the txv-video. This component cannot pass Modify the style of css

Introduce it in js

If you don’t want to control the plug-in in js, you don’t need to introduce it.

const TxvContext = requirePlugin(tencentVideo);
let txvContext = TxvContext.getTxvContext(\'txv1\');
txvContext.play(); //播放
Copy after login

This is the entire process of successfully quoting the Tencent video plug-in. I hope it can help people who have encountered problems using this plug-in.

MoreSmall program developmenttutorials , please pay attention to the PHP Chinese website!

The above is the detailed content of How to use Tencent video plug-in in mini program. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:zixun.jisuapp.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template