An Apsara Video SDK license binds one-to-one to an app identifier to authorize the SDK calls made by that app. After you obtain the license, integrate it into the corresponding Push SDK, short video SDK, ApsaraVideo Player SDK, or Queen SDK to complete SDK authorization. This topic describes how to integrate a license on web, Android and iOS clients.
Prerequisites
You have applied for a license and obtained the license file and the License Key. For more information, see Manage a license.
Authentication flow
As shown in the preceding figure, Apsara Video SDK license authentication depends on the License Key and the license file. The configuration requirements are as follows:
|
Item |
Required |
Description |
|||||
|
License Key |
Yes |
Used to request license file updates. The SDK checks for certificate file updates at initialization and checks again every 15 minutes at runtime. |
|||||
|
License file |
No. Recommended Configuration |
Authentication fallback when the server-side certificate request fails, such as during network outages. Stores enabled permissions and validity period. Update it when permissions change to maintain reliability in weak network conditions. Note
|
|||||
To skip the built-in license file, omit the LicenseFile configuration in the platform-specific steps below.
Without a built-in certificate file, authentication relies entirely on the server. Network issues may cause instability, and first-time users must wait for the certificate download before authentication succeeds.
ApsaraVideo Player SDK service environments
To meet global compliance requirements, ApsaraVideo Player SDK V6.14.0 and later provide multiple service environments that keep services localized and compliant. The environment that you select determines which service center supports license authentication and the playback quality data of ApsaraVideo Player SDK. Select the service environment that meets your requirements.
Alibaba Cloud International Website (www.alibabacloud.com) users can only use the Global (excluding the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China)) environment (Singapore node). V6.14.0 and later default to the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China) environment. Update the configuration to the international site environment as follows.
|
Environment |
Description |
|
The Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China) |
The Alibaba Cloud China Website (www.aliyun.com) environment (default). Uses the Shanghai, China node to serve users in the Chinese mainland, China (Hong Kong), China (Macao), and China (Taiwan). |
|
Global (excluding the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China)) |
The Alibaba Cloud International Website environment. Designed for International Website users. Uses the Singapore node to meet the compliance and performance requirements of specific regions. |
Integrate a license on the web client
-
Obtain the License Key from the console.
In the left-side navigation pane, choose SDK Management > My Licenses. On the License Management tab, find the License Key field and copy its value.
-
When initializing 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 applied for the license key: "example-key" // The License Key you can view in the console after a successful application } }); -
If no error messages appear after initialization, the license is configured successfully.
NoteThe page domain must match or be a subdomain of the domain registered in your license application. Otherwise, verification fails.
Integrate a license on Android
-
Configure the license.
-
(Recommended) Copy the certificate file to the assets directory in your Android Studio project.
NoteYou can place the certificate file elsewhere on the device, but ensure
com.aliyun.alivc_license.licensefile(for Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China)) orcom.aliyun.alivc_license.licensefile_SEA(for Global (excluding the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China))) matches the actual file path. -
In the AndroidManifest.xml file, add a <meta-data> node.
Important-
If verification fails after you configure the license, check whether the <meta-data> node is placed under the <application> element and whether the name of the <meta-data> node is correct. If the issue persists, see FAQ about licenses for troubleshooting.
-
For International Website (www.alibabacloud.com) users with ApsaraVideo Player SDK V6.14.0 or later, configure a license for the Global (excluding the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China)) environment. Without ApsaraVideo Player SDK, configure only the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China) environment.
-
You can integrate two sets of licenses: one for Global (excluding the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China)) and one for Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China). Set the player service environment each time the app starts. You cannot switch environments at runtime.
// Configure the 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 the 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 for the Global (excluding the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China)) environment).
ApsaraVideo Player SDK supports service environment selection from V6.14.0. V6.14.0 and later default to 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, which is currently the only environment available to International Website users, use one of the following methods to switch ApsaraVideo Player SDK to the international site environment. Otherwise, license authentication fails. Skip this step for other versions and other SDKs.
-
Method 1: Call the following API to update the default configuration to the international site environment.
// If you use the Global (excluding the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China)) environment, ensure you call the following interface to update the default configuration to the international site environment before calling any player API. This ensures all subsequent services run in the international site environment. // Use the unified AlivcBase interface to set the international site environment. You cannot modify the environment at runtime. AlivcBase.getEnvironmentManager().setGlobalEnvironment(AlivcEnv.GlobalEnv.ENV_SEA); -
Method 2 (Recommended): For ApsaraVideo Player SDK V7.6.0 and later, configure the international site environment using the
XMLmethod.In the
AndroidManifest.xmlfile, add a<meta-data>node.<meta-data android:name="com.aliyun.alivc_env" android:value="SEA"/>The following example shows a configuration:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> <application ...> <!-- Other configurations --> <meta-data android:name="com.aliyun.alivc_license.licensekey_SEA" android:value="xxx" /> <meta-data android:name="com.aliyun.alivc_license.licensefile_SEA" android:value="assets/SEALicense.crt" /> <meta-data android:name="com.aliyun.alivc_env" android:value="SEA"/> </application> </manifest>
-
Integrate a license on iOS
-
Configure the license.
-
Copy the certificate file
AliVideoCert-********.crtinto your Xcode project. Place it in the AppSupportFiles directory (recommended), the sandbox, or another path. In Target Membership, select the current project.In the Info.plist file of your project, add the following two configuration items:
-
AlivcLicenseFile (String): Set this to the certificate file name, for example,
license.crt. -
AlivcLicenseKey (String): Set this to the License Key value you obtained.
-
-
Open the Info.plist file. 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 the license file path that you obtained in Manage a license.
Important-
For International Website (www.alibabacloud.com) users with ApsaraVideo Player SDK V6.14.0 or later, configure a license for the Global (excluding the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China)) environment. Without ApsaraVideo Player SDK, configure only the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China) environment.
-
You can integrate two sets of licenses: one for Global (excluding the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China)) and one for Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China). Set the player service environment each time the app starts. You cannot switch environments at runtime.
// Configure the 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 the 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 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 Global (excluding the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China)) environment).
ApsaraVideo Player SDK supports service environment selection from V6.14.0. V6.14.0 and later default to 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, which is currently the only environment available to International Website users, use one of the following methods to switch ApsaraVideo Player SDK to the international site environment. Otherwise, license authentication fails. Skip this step for other versions and other SDKs.
-
Method 1: Call the following API to update the default configuration to the international site environment.
// If you use the Global (excluding the Chinese mainland, Hong Kong (China), Macao (China), and Taiwan (China)) environment, ensure you call the following interface to update the default configuration to the international site environment before calling any player API. This ensures all subsequent services run in the international site environment. // Use the unified AlivcBase interface to set the international site environment. You cannot modify the environment at runtime. AlivcBase.EnvironmentManager.globalEnvironment = ENV_SEA; -
Method 2 (Recommended): For ApsaraVideo Player SDK V7.6.0 and later, configure the international site environment using the
Info.Plistmethod.Open the
Info.plistfile and setAlivcEnvtoSEA.// Configure the current environment as the international site environment. <key>AlivcEnv</key> <string>SEA</string>You must also add the
SEALicense.crtcertificate file to the AppSupportFiles directory in your project. In the Info.plist file, configure the following key-value pairs:-
AlivcLicenseFile_SEA: Set toSEALicense.crt -
AlivcLicenseKey_SEA: Set to your License Key
-
-
Integrate a license on Flutter
Flutter is a cross-platform solution developed by Google. Therefore, on Flutter you must integrate the licenses of multiple platforms, or integrate the license that matches your business scenario. For more information, see Integrate a license on Android or Integrate a license on iOS.