The license of ApsaraVideo MediaBox SDK is bound to a unique App ID and authorizes your application to use the SDK. After obtaining a license, integrate it into the corresponding Push SDK, Short Video SDK, ApsaraVideo Player SDK, or Queen SDK to complete the authorization. This topic describes how to integrate the license on Web, Android, and iOS platforms.
Prerequisites
You have applied for a license and obtained the license file and license key. For more information, see Manage Licenses.
Authentication flowchart
As the figure shows, the ApsaraVideo MediaBox SDK license authentication uses the license key and the license file.
Item | Required | Description | |||||
License key | Yes | Used to request updates for the license file. The SDK checks for license file updates during initialization and every 15 minutes at runtime. | |||||
License file | No, but recommended | A fallback for authentication if the SDK fails to download the certificate from the server, for example, during network issues. The license file contains the enabled permissions and their validity period. To improve authentication success in unstable network conditions, update the embedded license file whenever permissions change. Note
| |||||
If you choose not to embed a license file, leave its configuration options empty. For more information, see the platform-specific instructions below.
If you do not configure an embedded license file, authentication relies entirely on the server. This can cause authentication to fail in unstable network conditions and requires users to wait for the certificate to download on first use. The time required depends on the user's network conditions.
Environments for ApsaraVideo Player SDK
To meet global compliance requirements, ApsaraVideo Player SDK V6.14.0 and later provides multiple service environments. The environment you select determines which regional service center handles license authentication and playback quality data. Choose the service environment that meets your needs.
Note that Alibaba Cloud International site users can only use the International environment (Singapore region). By default, ApsaraVideo Player SDK V6.14.0 and later uses the China environment. To ensure successful license authentication, you must switch to the International environment as described in this topic.
Environment | Description |
China | The default environment for Alibaba Cloud China site users. Services are delivered from the China (Shanghai) region to meet the access and authorization needs of users in the Chinese mainland, Hong Kong (China), Macau (China), and Taiwan. |
International | The environment for Alibaba Cloud International site users. Services are provided through the Singapore region to meet global compliance and performance requirements. |
Integrate the license on the web
Obtain the license key from the console.

When you initialize the player, pass the
licenseobject, which includes your registered domain name and license key:var player = new Aliplayer({ license: { domain: "example.com", // The domain name you provided when applying for the license. key: "example-key" // The license key from the console after your application is approved. } });If no errors are reported after initialization, the license is configured correctly.
NoteEnsure the domain is the same as, or a subdomain of, the domain you provided when applying for the license. Otherwise, license verification will fail.
Integrate the license on Android
Configure the license.
(Recommended) Copy the license file to the
assetsdirectory of your Android Studio project.NoteYou can also copy the file to another location on the device, but you must ensure that the value for
com.aliyun.alivc_license.licensefile(for China environment) orcom.aliyun.alivc_license.licensefile_SEA(for International environment) matches the license path in the next step.Add a <meta-data> node to the
AndroidManifest.xmlfile.ImportantIf verification fails after you configure the license, check whether the <meta-data> node is under the <application> element and whether the name of the <meta-data> is correct. If the issue persists, see FAQ about license for troubleshooting.
For International site users, to use ApsaraVideo Player SDK V6.14.0 or later, you must configure a license for the International environment. If you do not use ApsaraVideo Player SDK, you can configure a license only for the China environment.
You can integrate licenses for both the International and China environments. After each app startup, you can specify the player's service environment. The environment cannot be switched at runtime.

// Configure the license for the China environment (default configuration for Alibaba Cloud China site) <meta-data android:name="com.aliyun.alivc_license.licensekey" android:value="foIVziMaUHaRqgDyhf6b6eb8fcf014af39535d0720a32****"/> <!-- TODO: Set your License Key --> <meta-data android:name="com.aliyun.alivc_license.licensefile" android:value="assets/cert/release.crt"/> <!-- TODO: Set the path to your License File --> // Configure the license for International environment. Manually append _SEA to the name. <meta-data android:name="com.aliyun.alivc_license.licensekey_SEA" android:value="f6b6foIVziMaUHaRqgDyheb8fcf014af39535d0a32720****"/> <!-- TODO: Set your License Key --> <meta-data android:name="com.aliyun.alivc_license.licensefile_SEA" android:value="assets/cert/release.crt"/> <!-- TODO: Set the path to your License File -->
Configure the service environment for ApsaraVideo Player SDK (required for the International environment).
ApsaraVideo Player SDK V6.14.0 and later supports selecting a service environment. By default, the China environment is used. To switch to International environment (currently, International site users can only use this environment), you must choose one of the following methods to update the configuration. Otherwise, license authentication for ApsaraVideo Player SDK will fail. For other SDKs and versions, you can skip this step.
Method 1: Call the following API to switch from the default to the International environment.
// To use the International environment, call this API before any other player APIs to set the International environment. This ensures that all subsequent services run in the international environment. // This setting cannot be changed at runtime. AlivcBase.getEnvironmentManager().setGlobalEnvironment(AlivcEnv.GlobalEnv.ENV_SEA);Method 2 (Recommended): For ApsaraVideo Player SDK V7.6.0 and later, you can configure via XML.
In the
AndroidManifest.xmlfile, add the following information to the<meta-data>node.<meta-data android:name="com.aliyun.alivc_env" android:value="SEA"/>The following figure shows a configuration example:

Integrate the license on iOS
Configure the license.
In your Xcode project, copy the downloaded license file
AliVideoCert-********.crtinto your project. We recommend placing it in the AppSupportFiles directory, but you can also place it in the Sandbox or another path. Under Target Membership, select your project's target.
Open the
Info.plistfile. Modify the values for AlivcLicenseKey and AlivcLicenseFile (for the China environment) or AlivcLicenseKey_SEA and AlivcLicenseFile_SEA (for the International environment) to your license key and the path to your license file.ImportantFor International site users, to use ApsaraVideo Player SDK V6.14.0 or later, you must configure a license for the International environment. If you do not use ApsaraVideo Player SDK, you can configure a license only for the China environment.
You can integrate licenses for both the International and China environments. After each app startup, you can specify the player's service environment. The environment cannot be switched at runtime.
// Configure the license for the China environment (default). <key>AlivcLicenseFile</key> <string>XXX</string> <key>AlivcLicenseKey</key> <string>foIVziMaUHaRqgDyhf6b6eb8fcf014af39535d0720a32****</string> // Configure the license for the International environment. Manually append _SEA to the key name. <key>AlivcLicenseFile_SEA</key> <string>XXX</string> <key>AlivcLicenseKey_SEA</key> <string>f6b6efoIVziMaUHaRqgDyhb8fcf014af39535d0a32072****</string>
Configure the service environment for ApsaraVideo Player SDK (required for the International environment).
ApsaraVideo Player SDK V6.14.0 and later supports selecting a service environment. By default, the China environment is used. To switch to the International environment (currently, International site users can only use this environment), you must choose one of the following methods to update the configuration. Otherwise, license authentication for ApsaraVideo Player SDK will fail. For other SDKs and versions, you can skip this step.
Method 1: Call the following API to switch from the default to the International environment.
// To use the International environment, call this API before any other player APIs to set the International environment. This ensures that all subsequent services run in the international environment. // This setting cannot be changed at runtime. AlivcBase.EnvironmentManager.globalEnvironment = ENV_SEA;Method 2 (Recommended): For ApsaraVideo Player SDK V7.6.0 and later, you can configure the International environment via the
Info.plistfile.Open the
Info.plistfile and change the value of theAlivcEnvkey toSEA.// Configure the environment as the International environment. <key>AlivcEnv</key> <string>SEA</string>The following figure shows a configuration example:

Integrate the license on Flutter
Flutter is a multi-platform solution from Google. For Flutter apps, you must integrate the license natively for each target platform (Android and iOS). For more information, see Integrate the license on Android and Integrate the license on iOS.