tencent cloud

Feedback

Stage 2. Play back a video with hotlink protection enabled

Last updated: 2024-12-04 10:16:42

    Overview

    VOD supports hotlink protection configuration, which allows you to set the validity period, number of viewers, playback duration, etc. This document describes how to use the player to play back a video with hotlink protection enabled.
    Before reading this document, make sure that you have read Stage 1. Play back a video with Player in the Player Guide. This document uses the account activated and the video uploaded in stage 1.
    The example below shows how to enable key hotlink protection for the default distribution domain under your account:
    Note:
    Do not directly enable hotlink protection for the domain name in your production environment; otherwise, playback of videos in the production environment may fail.
    1. Log in to the VOD console, select Distribution and Playback > Domain Name, find the default distribution domain, and click Set on the right.
    
    
    2. Toggle Key Hotlink Protection on and click Generate to generate a random key (2WExxx48eW). Copy the generated key and click Confirm to save the configuration and make it take effect.
    
    

    Step 2. Preview video playback

    In the previous step, you have enabled hotlink protection for the default distribution domain name. Now, you can use the player for web, iOS, and Android to quickly preview video playback.
    1. Select Media Assets > Video Management, find the video uploaded and processed in step 1, click Manage in the Operation column, and select Player Preview.
    2. Select default for Player Configuration.
    Note:
    Default is a preset player configuration, which is used to output the adaptive bitstream with template 10 and the image sprite with template 10.
    
    3. As hotlink protection is enabled for the default distribution domain name, you can set the hotlink protection expiration time and the preview duration on the Playback Control tab. You can use the default parameter settings here (the default expiration time of playback hotlink protection is one day, and the preview duration and maximum number of IPs allowed for playback are left empty).
    
    4. In Web Player, click the button in the middle of the player to play back the video on web.
    
    5. In Mobile Player, click Scan code to download and install "Tencent Cloud Toolkit".
    
    6. Open Tencent Cloud Toolkit on your mobile phone, select Player, click the top-right corner to scan the QR code, and you can play back the video on your phone.
    

    Step 3. Use a demo for verification

    After hotlink protection is enabled, the player requires a signature within its validity period to play back the video. You can use the signature tool to quickly generate a signature.
    1. Enter the Player - Signature Generation Tool page and enter the following parameters:
    User appId: appId of video 1400xxx357(if a subapplication is used, enter the subapplication's appId).
    Video fileId: Video fileId, which is 528xxx3757278095.
    Current Unix Timestamp: Current Unix time automatically generated by the tool, which does not need to be entered manually and is 1591516390 here.
    Signature Expiration Unix Timestamp: Signature expiration time, which can be left empty. The signature will expire in one day by default.
    Link Expiration Time: Expiration time of key hotlink protection, which can be set to the hexadecimal Unix time after six hours: 5edcf146.
    Hotlink Protection Key: Hotlink protection key obtained in the previous step, which is 2WExxx48eW.
    2. Click Generate Signature, and the generated signature will be displayed in the "Signature Generation Result" text box.
    After getting the player signature, you can use the player demos for web, Android, and iOS for verification. For more information, see the demo source code.
    Note:
    In Media Assets > Video Management > Player Preview in the console, you can get the corresponding web player source code for video preview for your reference.
    
    

    Summary

    At this point, you have understood how to use the player to play back a video with hotlink protection enabled.
    You can also:
    Customize the video playback content and style as instructed in Stage 3. Customize playback content and style.
    Encrypt a video and play back the encrypted video as instructed in Stage 4. Play back an encrypted video.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support