tencent cloud

フィードバック

最終更新日:2024-04-17 11:49:14

    Introduction

    Application scenarios

    Advanced Picture-in-Picture (PIP) is an upgraded version of the basic PIP, mainly used for encrypted video PIP, offline playback PIP, and seamless switching from foreground to PIP scenes. It optimizes the implementation and logic, and achieves a true "instant switch" effect without long waiting times.
    Advantages of Advanced PIP:
    Encrypted video PIP: integrated with the existing player for encrypted playback, realizing PIP playback based on encrypted templates without the need to switch player types.
    Offline playback PIP: supports local video PIP playback, including ordinary videos, encrypted videos, etc.
    "Instant switch" effect: no need to click the PIP button to switch, just go to the background and PIP will start immediately, achieving a true "instant switch".

    Requirements

    System version: iOS ≥ 14.0, iPad ≥ 9.0 .
    Hardware devices: iPhone 8 and above.
    SDK version: 11.4 or above.

    Integration Steps

    Upgrade SDK version and configure resources

    1. Upgrade SDK version:

    Advanced Picture-in-Picture requires the use of the SDK. Before using the advanced Picture-in-Picture version, the SDK version needs to be upgraded to version 11.3 or above for the advanced version, or version 11.4 or above for the basic version, otherwise it cannot be used. At the same time, the basic and advanced versions of Picture-in-Picture can coexist with compatibility and no functional conflicts. If you want to upgrade the SDK version, please refer to the SDK integration guide.

    2. Introduce bundle resources

    Because the SDK needs to use resources from TXVodPlayer.bundle, the bundle file needs to be downloaded and introduced into the project before compilation. Please do not modify the bundle or the names of the resources used inside, as doing so may cause seamless switching of picture-in-picture to fail.
    
    
    

    3. Activate the premium version license for the player

    The advanced picture-in-picture version requires the mobile player premium version license. You can refer to the mobile player license guide to obtain it. If you have obtained the corresponding License, you can go to Tencent Cloud Cube Console > License Management > Mobile License to obtain the corresponding LicenseURL and LicenseKey. If you do not apply for the Player Advanced Package License, entering Picture-in-Picture will be invalid.
    After obtaining the License information, before calling the relevant interface of the SDK, initialize the License through the following interface. It is recommended to make the following settings in - [AppDelegate application:didFinishLaunchingWithOptions:]:
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    NSString * const licenceURL = @"<your license Url>";
    NSString * const licenceKey = @"<your license key>";
    
    //TXLiveBase is in "TXLiveBase.h"
    [TXLiveBase setLicenceURL:licenceURL key:licenceKey];
    NSLog(@"SDK Version = %@", [TXLiveBase getSDKVersionStr]);
    }

    Quick access to picture-in-picture function

    1. Permission granted

    Picture-in-picture (PictureInPicture) has been launched in iOS 9, but it was only available on the iPad before. To use picture-in-picture, the iPhone needs to be updated to iOS 14. Currently, Tencent Cloud Player can support in-app and out-of-app picture-in-picture capabilities, which greatly meets the needs of users. You need to enable background mode before use. The steps are: Select the corresponding Target > Signing & Capabilities > Background Modes in XCode and check "Audio, AirPlay, and Picture in Picture".
    
    img
    
    

    2. Set configuration options

    In order to use the automatic picture-in-picture function, you need to turn on the automatic picture-in-picture button in the settings. The specific path is to select on iPhone or iPad: Settings > General > Picture-in-Picture > Automatically turn on Picture-in-Picture, select to turn it on.
    
    
    

    3. Set proxy

    In order to facilitate monitoring of the picture-in-picture status, vodDelegate needs to be set to implement the picture-in-picture related callbacks in TXVodPlayListener. You can perform related business operations based on various status and error messages in the callback, such as continuing to play, pausing or exiting picture-in-picture, etc.
    /**
    * Picture-in-picture status callback
    *
    */
    - (void)onPlayer:(TXVodPlayer *)player pictureInPictureStateDidChange:(TX_VOD_PLAYER_PIP_STATE)pipState withParam:(NSDictionary *)param;
    
    /**
    * Picture-in-picture error message callback
    *
    */
    - (void)onPlayer:(TXVodPlayer *)player pictureInPictureErrorDidOccur:(TX_VOD_PLAYER_PIP_ERROR_TYPE)errorType withParam:(NSDictionary *)param;

    4. Code example using picture-in-picture capability

    Note:
    To use the automatic picture-in-picture function, make sure the player is in the playing state. If the player is paused or stopped, the automatic picture-in-picture function cannot be used.
    The isSupportSeamlessPictureInPicture interface can only be used after the application loads the advanced version License. At the same time, this interface can only determine whether the device itself supports automatic switching of picture-in-picture. Due to system limitations, it cannot determine the user's setting permission for automatic picture-in-picture, and needs to be guided by itself.
    Before playing, set whether to allow "automatic switching of picture-in-picture function".
    
    // 1. Before playing, set whether the "automatic switching Picture-In-Picture function" is allowed.
    // YES means allowed, NO means not allowed, the default is NO
    [TXVodPlayer setPictureInPictureSeamlessEnabled:YES];
    
    // 2. Enter picture-in-picture
    if (![TXVodPlayer isSupportPictureInPicture]) {
    //The device does not support picture-in-picture and exit directly.
    return;
    }
    
    // Manually call to enter picture-in-picture
    [_vodPlayer enterPictureInPicture];
    
    // 3. Exit the background operation. If the device supports seamless switching of picture-in-picture, the playback will not be paused when exiting the background.
    // Note: The isSupportSeamlessPictureInPicture interface can only be used after the application loads the advanced version License. At the same time, this interface can only determine the device itself
    // Whether automatic switching of picture-in-picture is supported? Due to system limitations, it is impossible to determine the user's setting permissions for automatic picture-in-picture. You need to guide it yourself.
    if ([self.vodplayer isSupportSeamlessPictureInPicture]) {
    // No processing
    } else {
    // Pause playback
    [self.vodplayer pause];
    }
    
    // 4. Exit picture-in-picture
    [_vodPlayer exitPictureInPicture];
    
    お問い合わせ

    カスタマーサービスをご提供できるため、ぜひお気軽にお問い合わせくださいませ。

    テクニカルサポート

    さらにサポートが必要な場合は、サポートチケットを送信して弊社サポートチームにお問い合わせください。24時間365日のサポートをご提供します。

    電話サポート(24 時間365日対応)