You must bind a license to your application to authorize the application to use ApsaraVideo MediaBox SDK. After you obtain a license, you need to bind the license to your application to authorize the application to use Push SDK, Short video SDK, ApsaraVideo Player SDK, or Queen SDK. This topic describes how to bind a license to a web application, an Android application, or an iOS application.
Prerequisites
A license is applied for, and the license key and license file are obtained. For more information, see the Apply for a license section of the "Manage licenses" topic.
Authentication flowchart
As shown in the preceding figure, ApsaraVideo MediaBox SDK authenticates an application by using a license key and a license file. The following table describes the configuration requirements for a license key and a license file.
Item | Required | Description | |||||
LicenseKey | Yes | The license key is used to request the latest license file. ApsaraVideo MediaBox SDK checks for an updated license file during initialization and then every 15 minutes once the application starts to run. | |||||
License file | No. We recommend that you configure a license file. | The built-in license file is used for authentication if a license file fails to be obtained from the server. For example, the built-in license file is used if the license file fails to be downloaded due to network issues. The license file includes the granted permissions and their validity period. To ensure a high authentication success rate in environments with weak network connectivity, we recommend that you proactively update the built-in license file whenever the granted permissions are changed. Note
|
If you do not want to configure a built-in license file, skip the related configurations when you bind a license to an application.
If no built-in license file is configured, authentication is complete based on the license file that is obtained from the server. This may cause authentication instability due to network issues. In addition, you may need to wait until the license file is downloaded if you use the application for the first time. The wait time depends on the actual network conditions.
Service environments for Player SDK
To meet global compliance requirements, ApsaraVideo Player SDK 6.14.0 and later provides multiple service environments to ensure that your service is localized and compliant. After you select a service environment for ApsaraVideo Player SDK, the service center in the selected service environment provides the data that is required for the license-based authentication and the data related to playback quality. You can select a service environment based on your business requirements. The following table describes the available service environments.
Users of the Alibaba Cloud international site (alibabacloud.com) can use only nodes in the Singapore region. By default, the global environment is configured for ApsaraVideo Player SDK 6.14.0 or later. To ensure smooth license-based authentication, you need to update the service environment to the Alibaba Cloud international site for ApsaraVideo Player SDK.
Environment | Description | Suggestion |
Global environment (default) | Services are provided by the nodes in the China (Shanghai) region of Alibaba Cloud to ensure that the access and authorization requirements of global users are met. | This environment is suitable for business in the Chinese mainland. Note If you are a user of the Alibaba Cloud international site (alibabacloud.com), you can use only nodes in the Singapore region. If you want to use nodes in the China (Shanghai) region of Alibaba Cloud, contact Alibaba Cloud for technical support. |
Alibaba Cloud international site (alibabacloud.com) | This environment is designed for users of the Alibaba Cloud international site (alibabacloud.com). In this environment, services are provided by the nodes in the Singapore region to meet the compliance and performance requirements in specific regions. | This environment is suitable for business in the China (Hong Kong), China (Macao), and China (Taiwan) regions and regions outside the Chinese mainland. |
Bind a license to a web application
Obtain the license key in the ApsaraVideo VOD console.
Configure the license information when you initialize the player, such as your domain name and the license key.
var player = new Aliplayer({ license: { domain: "example.com", // The domain name that you specify when you apply for a license. key: "example-key" // The license key that is displayed in the ApsaraVideo VOD console after a license is applied. } });
If no error message is returned after you initialize the player, the license is configured.
NoteThe domain name of the page on which the player is deployed must be a subdomain of or the same as the web domain name that you specified when you applied for the license. Otherwise, the license verification fails. The localhost does not verify the domain name.
Bind a license to an Android application
Configure a license.
Recommended. Copy the license file to the assets directory in your Android Studio project.
NoteYou can also copy the license file to another directory on your device. If you do so, make sure that the value that corresponds to
com.aliyun.alivc_license.licensefile
in the global environment orcom.aliyun.alivc_license.licensefile_SEA
on the Alibaba Cloud international site (alibabacloud.com) in Step 2 is the same as the path of the license file.Add <meta-data> elements to the AndroidManifest.xml file.
ImportantIf the authentication fails after you configure the license, check whether the <meta-data> elements are added under the <application> element and whether the names in the <meta-data> elements are correct. If the issue persists, troubleshoot the issue by referring to the FAQ about licenses topic.
If you want to use ApsaraVideo Player SDK 6.14.0 or later on the Alibaba Cloud international site (alibabacloud.com), you must configure a license for the Alibaba Cloud international site (alibabacloud.com). If you do not use ApsaraVideo Player SDK, you can configure a license for the global environment.
You can bind two licenses to your application at the same time, including a license for the global environment and a license for the Alibaba Cloud international site (alibabacloud.com). Then, you can specify the environment to use the player by configuring the service environment for ApsaraVideo Player SDK each time you start your application. You cannot switch the environment when the player is running.
// Configure a license for the global environment. This is the default configuration. <meta-data android:name="com.aliyun.alivc_license.licensekey" android:value="foIVziMaUHaRqgDyhf6b6eb8fcf014af39535d0720a32****"/> <!-- TODO: Specify the license key.--> <meta-data android:name="com.aliyun.alivc_license.licensefile" android:value="assets/cert/release.crt"/> <!-- TODO: Specify the path of your license file.--> // Configure a license for the Alibaba Cloud international site (alibabacloud.com) and manually add _SEA to the end of the license name. <meta-data android:name="com.aliyun.alivc_license.licensekey_SEA" android:value="f6b6foIVziMaUHaRqgDyheb8fcf014af39535d0a32720****"/> <!-- TODO: Specify the license key.--> <meta-data android:name="com.aliyun.alivc_license.licensefile_SEA" android:value="assets/cert/release.crt"/> <!-- TODO: Specify the path of your license file.-->
Configure a service environment for ApsaraVideo Player SDK. This step is required if you use the Alibaba Cloud international site (alibabacloud.com).
ApsaraVideo Player SDK 6.14.0 and later allows you to select a service environment. By default, the global environment is configured for ApsaraVideo Player SDK 6.14.0 and later. Users of the Alibaba Cloud international site (alibabacloud.com) cannot use the global environment. If you want to use the Alibaba Cloud international site (alibabacloud.com), you must update the service environment to the Alibaba Cloud international site (alibabacloud.com) for ApsaraVideo Player SDK by using the following method each time you start your application. Otherwise, the license that authorizes your application to use ApsaraVideo Player SDK fails the authentication. You can ignore this step if you use ApsaraVideo Player SDK of a version that is earlier than 6.14.0 or in other scenarios.
// When you use the Alibaba Cloud international site (alibabacloud.com), make sure that you have called the following operation to update the default environment to the Alibaba Cloud international site (alibabacloud.com) before you call an API operation of the player. This ensures that all subsequent services run on the Alibaba Cloud international site (alibabacloud.com). // Configure the environment to the Alibaba Cloud international site (alibabacloud.com) by calling the unified API operation of AlivcBase. You cannot change the environment when the player is running. AlivcBase.getEnvironmentManager().setGlobalEnvironment(AlivcEnv.GlobalEnv.ENV_SEA);
Bind a license to an iOS application
Configure a license.
Copy the license file to the specified directory of the Xcode project and select the current project in Target Membership.
Open the Info.plist file. Set the AlivcLicenseKey and AlivcLicenseFile parameters in the global environment, or the AlivcLicenseKey_SEA and AlivcLicenseFile_SEA parameters on the Alibaba Cloud international site (alibabacloud.com) to the license key and license file path that you obtained when you applied for the license.
ImportantIf you want to use ApsaraVideo Player SDK 6.14.0 or later on the Alibaba Cloud international site (alibabacloud.com), you must configure a license for the Alibaba Cloud international site (alibabacloud.com). If you do not use ApsaraVideo Player SDK, you can configure a license for the global environment.
You can bind two licenses to your application at the same time, including a license for the global environment and a license for the Alibaba Cloud international site (alibabacloud.com). Then, you can specify the environment to use the player by configuring the service environment for ApsaraVideo Player SDK each time you start your application. You cannot switch the environment when the player is running.
// Configure a license for the global environment. This is the default configuration. <key>AlivcLicenseFile</key> <string>XXX</string> <key>AlivcLicenseKey</key> <string>foIVziMaUHaRqgDyhf6b6eb8fcf014af39535d0720a32****</string> // Configure a license for the Alibaba Cloud international site (alibabacloud.com) and manually add _SEA to the end of the license name. <key>AlivcLicenseFile_SEA</key> <string>XXX</string> <key>AlivcLicenseKey_SEA</key> <string>f6b6efoIVziMaUHaRqgDyhb8fcf014af39535d0a32072****</string>
Configure a service environment for ApsaraVideo Player SDK.
ApsaraVideo Player SDK 6.14.0 and later allows you to select a service environment. By default, the global environment is configured for ApsaraVideo Player SDK 6.14.0 and later. Users of the Alibaba Cloud international site (alibabacloud.com) cannot use the global environment. If you want to use the Alibaba Cloud international site (alibabacloud.com), you must update the service environment to the Alibaba Cloud international site (alibabacloud.com) for ApsaraVideo Player SDK by using the following method each time you start your application. Otherwise, the license that authorizes your application to use ApsaraVideo Player SDK fails the authentication. You can ignore this step if you use ApsaraVideo Player SDK of a version that is earlier than 6.14.0 or in other scenarios.
// When you use the Alibaba Cloud international site (alibabacloud.com), make sure that you have called the following operation to update the default environment to the Alibaba Cloud international site (alibabacloud.com) before you call an API operation of the player. This ensures that all subsequent services run on the Alibaba Cloud international site (alibabacloud.com). // Configure the environment to the Alibaba Cloud international site (alibabacloud.com) by calling the unified API operation of AlivcBase. You cannot change the environment when the player is running. AlivcBase.EnvironmentManager.globalEnvironment = ENV_SEA;