![]() |
AliyunPlayer v7.10.0
Aliyun Player API Reference Manual for iOS Platforms
|
#include "AliPlayerGlobalSettings.h"
Public Types | |
| typedef NSString *(* | AdaptiveDecoderGetBackupURLCallback) (AVPBizScene oriBizType, AVPCodecType oriCodecType, NSString *oriURL) |
| Callback function type for obtaining a backup URL during adaptive decoder downgrade. | |
| typedef NSString *(* | CaheUrlHashCallback) (NSString *url) |
| This callback generates a unique identifier for each media URL, used for cache indexing. | |
| typedef BOOL(* | NetworkDataProcessCallback) (NSString *requestUrl, const uint8_t *inData, const int64_t inOutSize, uint8_t *outData) |
| A chance for media data downloading from network and modified by app, now only mp4 is supported. | |
Class Methods | |
| (void) | + clearCaches |
| Clears all local cache files. | |
| (void) | + disableCrashUpload: |
| Sets whether to disable crash stack trace upload. | |
| (void) | + enableAdaptiveIpDegrade: |
| Sets whether to enable adaptive IP degrade strategy. | |
| (void) | + enableBufferToLocalCache: |
| Enables buffering overflow to local cache. | |
| (void) | + enableCodecPlugin:valid: |
| Enables or disables a specific codec plugin. | |
| (void) | + enableEnhancedHttpDns: |
| Enables enhanced HTTP DNS. | |
| (void) | + enableEnhancedNetworkBalance: |
| Enables the enhanced built-in network load balancing strategy among multiple player instances. | |
| (void) | + enableHttpDns: |
| Enables standard HTTP DNS. | |
| (void) | + enableHWAduioTempo: |
| Enables or disables hardware-accelerated audio tempo scaling. | |
| (NSString *) | + enableLocalCache: |
| Enables or disables local caching. | |
| (void) | + enableLocalCache:maxBufferMemoryKB:localCacheDir: |
| Enables or disables local caching and specifies the cache directory. | |
| (void) | + enableNetworkBalance: |
| Enables the built-in network balance mechanism. | |
| (void) | + forceAudioRendingFormat:fmt:channels:sample_rate: |
| Forces the audio renderer to use a specified PCM format. | |
| (void) | + setAdaptiveDecoderGetBackupURLCallback: |
| Set the callback to get backup url. | |
| (void) | + setCacheFileClearConfig:maxCapacityMB:freeStorageMB: |
| Settings related to automatic clearing of local cache files. | |
| (void) | + setCacheUrlHashCallback: |
| Sets the hash callback to load the URL. | |
| (void) | + setDNSResolve:ip: |
| Sets a DNS IP mapping for a specific host. | |
| (void) | + setFairPlayCertID: |
| Sets the FairPlay user certificate ID. | |
| (void) | + setIpResolveType: |
| Sets the IP address type used during DNS resolution. | |
| (void) | + setNetworkDataProcessCallback: |
| Set the network data callback. | |
| (void) | + setOption:value: |
| Sets a global string-type feature option. | |
| (void) | + setOption:valueInt: |
| Sets a global integer-type feature option. | |
| (void) | + setUseHttp2: |
| Sets whether to use HTTP/2 protocol. | |
| - (typedef NSString *(* AdaptiveDecoderGetBackupURLCallback) (AVPBizScene oriBizType, AVPCodecType oriCodecType, NSString *oriURL)) |
Callback function type for obtaining a backup URL during adaptive decoder downgrade.
When a decoder downgrade is triggered due to insufficient decoding exception, the SDK invokes this callback to obtain an alternative playback URL.
| oriBizType | The business scenario that triggered the downgrade, defined by AVPBizScene |
| oriCodecType | The original codec type that triggered the downgrade, defined by AVPCodecType |
| oriURL | The original playback URL |
| - (typedef NSString *(* CaheUrlHashCallback) (NSString *url)) |
This callback generates a unique identifier for each media URL, used for cache indexing.
Different URLs must produce different hash values.
| url | The media resource URL |
| - (typedef BOOL(* NetworkDataProcessCallback) (NSString *requestUrl, const uint8_t *inData, const int64_t inOutSize, uint8_t *outData)) |
A chance for media data downloading from network and modified by app, now only mp4 is supported.
| requestUrl | data's source URL |
| inData | input data buffer |
| inOutSize | input/output data buffer size in byte |
| outData | output data buffer and its memory is managed by sdk, app can write it but size must not exceed to inOutSize |
| + (void) clearCaches |
Clears all local cache files.
This operation deletes all cache content generated by the player, including media and metadata.
| + (void) disableCrashUpload: | (BOOL) | disable |
Sets whether to disable crash stack trace upload.
When enabled, the player will not upload stack traces upon crash.
| disable | true to disable crash upload, false to enable it (default) |
| + (void) enableAdaptiveIpDegrade: | (BOOL) | enable |
Sets whether to enable adaptive IP degrade strategy.
Enabled by default.
When enabled, the SDK can automatically apply different IP strategies based on network conditions or server responses to improve playback stability. Please ensure that the playback domain name is added and configured with corresponding functions on the alicdn platform to ensure that online services can be provided. For configuration methods, please refer to: https://www.alibabacloud.com/product/content-delivery-network
| enable | true to enable adaptive IP degrade, false to disable this feature |
| + (void) enableBufferToLocalCache: | (BOOL) | enable |
Enables buffering overflow to local cache.
When enabled, if maxBufferDuration is set to more than 50 seconds, the portion exceeding 50 seconds is cached locally.
Disabled by default.
| enable | Whether to enable buffer overflow caching |
| + (void) enableCodecPlugin: | (NSString *) | target | |
| valid: | (BOOL) | valid |
Enables or disables a specific codec plugin.
| target | The codec plugin identifier; if empty, the call is ignored |
| valid | true to enable the plugin, false to disable it |
| + (void) enableEnhancedHttpDns: | (BOOL) | enable |
Enables enhanced HTTP DNS.
After enabling, note the following:
| enable | Whether to enable enhanced HTTP DNS. Default is enabled. |
| + (void) enableEnhancedNetworkBalance: | (BOOL) | enable |
Enables the enhanced built-in network load balancing strategy among multiple player instances.
When enabled, it automatically balances the network load between different player instances during playback. Default is enabled.
Note:
+enableNetworkBalance:; if enableNetworkBalance is disabled, this strategy will also be disabled. +enableNetworkBalance: itself. | enable | Whether to enable the enhanced network balancing strategy |
| + (void) enableHttpDns: | (BOOL) | enable |
Enables standard HTTP DNS.
Deprecated: This API has been removed. Enhanced HTTP DNS is enabled by default.
Do not call this method.
| enable | Whether to enable HTTP DNS (this parameter has no effect) |
| + (void) enableHWAduioTempo: | (bool) | enable |
Enables or disables hardware-accelerated audio tempo scaling.
When disabled, software-based tempo scaling is used instead.
This setting affects the PCM data format in audio rendering callbacks.
If this setting is modified, it must be done on the same thread.
Enabled by default.
| enable | Whether to enable hardware audio tempo scaling |
| + (NSString *) enableLocalCache: | (BOOL) | enable |
Enables or disables local caching.
When enabled, media content is cached to local files.
Disabled by default.
| enable | true to enable local cache, false to disable it |
| + (void) enableLocalCache: | (bool) | enable | |
| maxBufferMemoryKB: | (int) | maxBufferMemoryKB | |
| localCacheDir: | (NSString *) | localCacheDir |
Enables or disables local caching and specifies the cache directory.
When enabled, media content is cached to the specified local directory.
Note: The parameter maxBufferMemoryKB is deprecated and has no effect.
Disabled by default.
| enable | true to enable local cache, false to disable it |
| maxBufferMemoryKB | This parameter is deprecated and has no effect |
| localCacheDir | Absolute path to the local cache directory |
| + (void) enableNetworkBalance: | (BOOL) | enable |
Enables the built-in network balance mechanism.
When enabled, the player automatically controls the timing of media loader (see AliMediaLoader) during playback to optimize network resource usage.
Enabled by default.
| enable | Whether to enable the network balance mechanism |
| + (void) forceAudioRendingFormat: | (bool) | force | |
| fmt: | (NSString *) | fmt | |
| channels: | (int) | channels | |
| sample_rate: | (int) | sample_rate |
Forces the audio renderer to use a specified PCM format.
If the specified format is not supported by the device, the setting has no effect and the default format is used.
Out-of-range parameters (e.g., invalid channel count or sample rate) are ignored.
This setting affects the PCM data format in audio rendering callbacks.
If this setting is modified, it must be done on the same thread.
Disabled by default.
| force | Whether to enable forced format setting |
| fmt | PCM format; currently only "s16" (16-bit signed integer) is supported |
| channels | PCM channel count; valid range is 1–8 |
| sample_rate | PCM sample rate in Hz; valid range is 1–48000 |
| + (void) setAdaptiveDecoderGetBackupURLCallback: | (AdaptiveDecoderGetBackupURLCallback) | callback |
Set the callback to get backup url.
| callback | The callback for obtaining a backup URL; |
| + (void) setCacheFileClearConfig: | (int64_t) | expireMin | |
| maxCapacityMB: | (int64_t) | maxCapacityMB | |
| freeStorageMB: | (int64_t) | freeStorageMB |
Settings related to automatic clearing of local cache files.
| expireMin | How long the cache expires: the unit is minute. The default value is 30 days. |
| maxCapacityMB | maximum cache capacity: in megabytes. The default value is 2GB. If the total cache size exceeds this size, some caches are discarded one by one in the cacheItem granularity until they are smaller than or equal to the maximum cache capacity. Recommend 500MB if based on short video bussiness. |
| freeStorageMB | Minimum free disk capacity: in megabytes. The default value is 1GB. If the current disk capacity is less than this value, the freeStorage will be eliminated one by one until the freeStorage is greater than or equal to this value or all caches are eliminated. |
| + (void) setCacheUrlHashCallback: | (CaheUrlHashCallback) | callback |
Sets the hash callback to load the URL.
If not set, the SDK uses the built-in MD5 algorithm to generate hash values.
| callback | Custom hash generation callback; set to nil to revert to MD5 |
| + (void) setDNSResolve: | (NSString *) | host | |
| ip: | (NSString *) | ip |
Sets a DNS IP mapping for a specific host.
This method customizes DNS resolution by mapping a given host (with port) to a fixed IP address.
Setting an empty string clears the existing mapping.
| host | The host name with port (HTTP default port is 80, HTTPS default port is 443), e.g., player.alicdn.com:443 |
| ip | The corresponding IP address; set to an empty string to clear the mapping |
| + (void) setFairPlayCertID: | (NSString *) | certID |
Sets the FairPlay user certificate ID.
Each update of the certificate ID must be performed on the same thread used for the initial setting; otherwise, the update will have no effect.
| certID | The user certificate ID string |
| + (void) setIpResolveType: | (AVPIpResolveType) | type |
Sets the IP address type used during DNS resolution.
This setting affects all subsequent DNS resolution behavior.
| type | The IP type, defined by the AVPIpResolveType enum |
| + (void) setNetworkDataProcessCallback: | (NetworkDataProcessCallback) | callback |
Set the network data callback.
| + (void) setOption: | (GlobalOption) | key | |
| value: | (NSString *) | value |
Sets a global string-type feature option.
This method configures low-level parameters that affect all player instances.
Note: Certain options (e.g., MAX_ERROR_FRAMES_HARDWARE_DECODE) are ignored in this overload; use the integer overload instead.
| key | The option key, defined as an integer constant by the SDK, |
GlobalOption | value | The corresponding string value for the option |
| + (void) setOption: | (GlobalOption) | key | |
| valueInt: | (int) | value |
Sets a global integer-type feature option.
This method configures low-level parameters that affect all player instances.
| key | The option key, defined as an integer constant by the SDK, |
GlobalOption | valueInt | The corresponding integer value for the option |
| + (void) setUseHttp2: | (bool) | use |
Sets whether to use HTTP/2 protocol.
HTTP/2 is enabled by default since SDK version v5.5.0.0.
| use | Whether to enable HTTP/2 |