A license for the ApsaraVideo MediaBox SDK is bound to an application's identity, which authorizes the application to call the SDK. After you obtain an SDK license, you must integrate the license into the corresponding Push SDK, short video SDK, ApsaraVideo Player SDK, or Queen SDK to complete the authorization. This topic describes how to integrate a license on Web, Android and iOS clients.
Prerequisites
You have requested a license and obtained the license file and license key. For more information, see Manage licenses.
Authorization flow
As shown in the preceding figure, the license authorization flow for the ApsaraVideo MediaBox SDK depends on the LicenseKey and the license file. The configuration requirements are as follows:
Item | Required | Description | |||||
LicenseKey | Yes | Used to request updates for the license file. The SDK checks for updates to the certificate file during initialization and every 15 minutes during runtime. | |||||
License file | No, but recommended. | The certificate file used for authorization when the certificate cannot be successfully requested from the server. This can happen in extreme scenarios, such as when a network issue prevents the certificate from being downloaded. The certificate file contains the granted permissions and the validity period. To improve the authorization success rate in weak network conditions, update the built-in certificate file when permissions change. Note
| |||||
If you do not want to use a built-in license file for special reasons, you can leave the LicenseFile-related configurations empty. For more information, see the following sections.
If you do not configure a built-in certificate file, authorization relies entirely on the server. This can lead to unstable authorization due to network instability. It may also require users to wait for the certificate to download before they can be authorized when they first use the application. The time required depends on the user's network conditions.
ApsaraVideo Player SDK service environment
To meet global compliance requirements, ApsaraVideo Player SDK V6.14.0 and later provides various environment options to ensure service localization and compliance. Based on your selected service environment, the license authorization and playback quality service data for ApsaraVideo Player SDK is handled by the corresponding service center. You can select a service environment as needed.
Note that users of the Alibaba Cloud international site can only use the Global (excluding the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China)) environment (Singapore node). ApsaraVideo Player SDK V6.14.0 and later uses the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China) environment configuration by default. To ensure a smooth license authorization process, you must update the ApsaraVideo Player SDK configuration to the international site environment as described below.
Environment | Description |
Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China) | China site (aliyun.com) environment (default). The service is provided through the Alibaba Cloud node in Shanghai, China, to meet the access and authorization needs of users in the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China). |
Global (excluding the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China)) | International site (alibabacloud.com) environment: An environment designed for users of the international site that provides services from the Singapore node to meet the compliance and performance requirements of specific regions. |
Integrate a license on a web client
Obtain the License Key from the console.

When you initialize the player, pass the `license` field, which includes the registered domain name and the License Key.
var player = new Aliplayer({ license: { domain: "example.com", // The domain name you entered when you requested the license key: "example-key" // The License Key that is displayed in the console after the request is approved } });After the player is initialized, if no errors are reported, the license is configured.
NoteMake sure that the domain name of the page where the player is located is the same as the domain name you entered when you requested the license, or is a subdomain of the entered domain name. Otherwise, the license verification fails.
Integrate a license on an Android client
Configure the license.
(Recommended) Copy the certificate file to the `assets` folder of your Android Studio project.
NoteYou can also copy the certificate file to another location on the device. However, you must make sure that the value of
com.aliyun.alivc_license.licensefile(Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China)) orcom.aliyun.alivc_license.licensefile_SEA(Global (excluding the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China))) in the next step is the same as the path of the license file.Add a <meta-data> node to the `AndroidManifest.xml` file.
ImportantIf the verification fails after you configure the license, check whether the <meta-data> node is under the <application> element and whether the name of <meta-data> is correct. If the issue persists, see FAQ about licenses for troubleshooting.
For users of the international site, if you use ApsaraVideo Player SDK V6.14.0 or later, you must configure a license for the Global (excluding the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China)) environment. If you do not use ApsaraVideo Player SDK, you can only configure a license for the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China) environment.
You can integrate two sets of licenses at the same time (one for the Global (excluding the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China)) environment and one for the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China) environment). Then, each time the app starts, you can specify the runtime environment for the player by configuring the ApsaraVideo Player SDK service environment. You cannot switch the environment while the player is running.

// Configure a license for the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China) (default China site configuration) <meta-data android:name="com.aliyun.alivc_license.licensekey" android:value="foIVziMaUHaRqgDyhf6b6eb8fcf014af39535d0720a32****"/> <!-- TODO: Set your LicenseKey value. --> <meta-data android:name="com.aliyun.alivc_license.licensefile" android:value="assets/cert/release.crt"/> <!-- TODO: Set the path of your license file. --> // Configure a license for the Global (excluding the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China)) environment. Manually add _SEA to the end of the name. <meta-data android:name="com.aliyun.alivc_license.licensekey_SEA" android:value="f6b6foIVziMaUHaRqgDyheb8fcf014af39535d0a32720****"/> <!-- TODO: Set your LicenseKey value. --> <meta-data android:name="com.aliyun.alivc_license.licensefile_SEA" android:value="assets/cert/release.crt"/> <!-- TODO: Set the path of your license file. -->
Configure the service environment for ApsaraVideo Player SDK (required if you use the Global (excluding the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China)) environment).
ApsaraVideo Player SDK V6.14.0 and later lets you select a service environment. The default configuration is for the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China) environment. To use the Global (excluding the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China)) environment (currently, users of the international site can only use this environment), you must use one of the following methods to update the ApsaraVideo Player SDK configuration to the international site environment. Otherwise, the license authorization for ApsaraVideo Player SDK will fail. For other SDK versions and scenarios, you can skip this step.
Method 1: Call the following method to update the default configuration to the international site environment.
// When using the Global (excluding the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China)) environment, make sure to call the following interface to update the default configuration to the international site environment before calling any player API. This ensures that all subsequent services run in the international site environment. // Use the unified AlivcBase interface to set the international site environment. The environment cannot be modified during runtime. AlivcBase.getEnvironmentManager().setGlobalEnvironment(AlivcEnv.GlobalEnv.ENV_SEA);Method 2 (Recommended): For ApsaraVideo Player SDK V7.6.0 and later, you can configure the international site environment using the
XMLmethod.Add a
<meta-data>node to theAndroidManifest.xmlfile.<meta-data android:name="com.aliyun.alivc_env" android:value="SEA"/>The following figure shows a configuration example.

Integrate a license on an iOS client
Configure the license.
Add the
AliVideoCert-********.crtcertificate file to your Xcode project. We recommend placing it in the AppSupportFiles folder, but you can also place it in the sandbox or another path. In Target Membership, select the current project.
Open `Info.plist`. Set AlivcLicenseKey and AlivcLicenseFile for the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China) environment, or AlivcLicenseKey_SEA and AlivcLicenseFile_SEA for the Global (excluding the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China)) environment, to the License Key and license file path obtained from Manage licenses.
ImportantFor users of the international site, if you use ApsaraVideo Player SDK V6.14.0 or later, you must configure a license for the Global (excluding the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China)) environment. If you do not use ApsaraVideo Player SDK, you can only configure a license for the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China) environment.
You can integrate two sets of licenses at the same time (one for the Global (excluding the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China)) environment and one for the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China) environment). Then, each time the app starts, you can specify the runtime environment for the player by configuring the player's service environment. You cannot switch the environment while the player is running.
// Configure a license for the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China) (default configuration) <key>AlivcLicenseFile</key> <string>XXX</string> <key>AlivcLicenseKey</key> <string>foIVziMaUHaRqgDyhf6b6eb8fcf014af39535d0720a32****</string> // Configure a license for the Global (excluding the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China)) environment. Manually add _SEA to the end of the key. <key>AlivcLicenseFile_SEA</key> <string>XXX</string> <key>AlivcLicenseKey_SEA</key> <string>f6b6efoIVziMaUHaRqgDyhb8fcf014af39535d0a32072****</string>
Configure the service environment for ApsaraVideo Player SDK (required if you use the Global (excluding the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China)) environment).
ApsaraVideo Player SDK V6.14.0 and later lets you select a service environment. The default configuration is for the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China) environment. To use the Global (excluding the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China)) environment (currently, users of the international site can only use this environment), you must use one of the following methods to update the ApsaraVideo Player SDK configuration to the international site environment. Otherwise, the license authorization for ApsaraVideo Player SDK will fail. For other SDK versions and scenarios, you can skip this step.
Method 1: Call the following method to update the default configuration to the international site environment.
// When using the Global (excluding the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China)) environment, make sure to call the following interface to update the default configuration to the international site environment before calling any player API. This ensures that all subsequent services run in the international site environment. // Use the unified AlivcBase interface to set the international site environment. The environment cannot be modified during runtime. AlivcBase.EnvironmentManager.globalEnvironment = ENV_SEA;Method 2 (Recommended): For ApsaraVideo Player SDK V7.6.0 and later, you can configure the international site environment using the
Info.plistmethod.Open the
Info.plistfile and setAlivcEnvtoSEA.// Set the current environment to the international site environment. <key>AlivcEnv</key> <string>SEA</string>The following figure shows a configuration example.

Integrate a license on a Flutter client
Flutter is a cross-platform solution developed by Google. Therefore, for a Flutter client, you must integrate the licenses for both Android and iOS, or integrate the appropriate license based on your business scenario. For more information, see Integrate a license on an Android client or Integrate a license on an iOS client.