const Koa = require('koa')const cors = require('koa2-cors')const app = new Koa()const tencentcloud = require("tencentcloud-sdk-nodejs")app.use(cors()) // CORS configurationapp.use(async (ctx) => {// The URI request in the generated m3u8 file will carry the parameters by defaultconst { Ciphertext, KMSRegion } = ctx.queryconst KmsClient = tencentcloud.kms.v20190118.Clientconst clientConfig = {credential: {// Account API key, which can be obtained at https://console.tencentcloud.com/cam/capisecretId: "SecretId",secretKey: "SecretKey",},region: KMSRegion, // Region, such as "ap-guangzhou"profile: {httpProfile: {endpoint: "kms.tencentcloudapi.com",},},};// Create a KMS object instanceconst client = new KmsClient(clientConfig);const params = {"CiphertextBlob": Ciphertext,};try {// Initiate a request to get the decryption keyconst res = await client.Decrypt(params)// Take out the key and return its binary data after Base64-decryptionconst plaintext = res.Plaintextconst plainBuff = Buffer.from(plaintext, 'base64');ctx.body = plainBuff} catch (error) {console.log(error);}})// Listen on port 8080.app.listen('8080', () => {console.log('127.0.0.1:8080');})
<!--Player style file--><link href="https://web.sdk.qcloud.com/player/tcplayer/release/v4.2.2/tcplayer.min.css" rel="stylesheet"/><!--If you want to play back HLS videos through HTML5 in a browser such as Chrome and Firefox, you need to import `hls.min.0.13.2m.js` before importing `tcplayer.v4.2.2.min.js`.--><script src="https://web.sdk.qcloud.com/player/tcplayer/release/v4.2.2/libs/hls.min.0.13.2m.js"></script><!--Player script file--><script src="https://web.sdk.qcloud.com/player/tcplayer/release/v4.2.2/tcplayer.v4.2.2.min.js"></script>
index.html
(the container ID, width, and height are customizable).<video id="player-container-id" width="414" height="270" preload="auto" playsinline webkit-playsinline></video>
<video>
tag.player-container-id
in the sample is the ID of the player container, which can be customized.preload
attribute in the sample specifies whether to load the video after the page is loaded, which is usually set to auto
for faster start of the playback. Other options include meta
(only loads the metadata after the page is loaded) and none
(does not load the video after the page is loaded). Due to system restrictions, videos will not be automatically loaded on mobile devices.playsinline
and webkit-playsinline
attributes are used to implement inline playback when the standard mobile browser does not hijack the video playback. They are just for reference here and can be used as needed.x5-playsinline
attribute is set, the X5 UI player will be used in the TBS kernel.var player = TCPlayer('player-container-id', {}); // `player-container-id` is the player container ID, which must be the same as that in HTMLplayer.src(https://examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com/path/example.m3u8); // m3u8 object address
Was this page helpful?