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

How to use Tencent Video plug-in in WeChat mini program?

青灯夜游
青灯夜游forward
2020-04-01 09:37:316463browse

How to use Tencent video plug-in in WeChat applet development? The following article will introduce you to the tutorial on how to use the Tencent video plug-in. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

How to use Tencent Video plug-in in WeChat mini program?

Abstract: 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, so that you can Reference Tencent Video in the page without using your own server for video playback, which saves a lot of server expenses.

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, so that you can reference Tencent Video in the page without using your own The server plays the video, saving 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 mini programs.

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
    }

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
}

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

Use components in the page

Enter the wxml file and add

This step is very simple, vid is the vid of Tencent Video, playerid is the unique identification code of the txv-video, this component cannot be styled through CSS

Introduce 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(); / /Play

This is the entire process of successfully quoting the Tencent Video plug-in. I hope it can help people who also encounter problems using this plug-in.

Recommendation: " Mini Program Development Tutorial"

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

Statement:
This article is reproduced at:jisuapp.cn. If there is any infringement, please contact admin@php.cn delete