AliyunPlayer v7.10.0
Aliyun Player API Reference Manual for iOS Platforms
Loading...
Searching...
No Matches
AliPlayerGlobalSettings Class Reference

#include "AliPlayerGlobalSettings.h"

Inheritance diagram for AliPlayerGlobalSettings:

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.

Member Typedef Documentation

◆ AdaptiveDecoderGetBackupURLCallback

- (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.

Parameters
oriBizTypeThe business scenario that triggered the downgrade, defined by AVPBizScene
oriCodecTypeThe original codec type that triggered the downgrade, defined by AVPCodecType
oriURLThe original playback URL
Returns
The backup playback URL; if nil or empty string is returned, no URL switching occurs

◆ CaheUrlHashCallback

- (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.

Parameters
urlThe media resource URL
Returns
A unique hash string for the URL

◆ NetworkDataProcessCallback

- (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.

Parameters
requestUrldata's source URL
inDatainput data buffer
inOutSizeinput/output data buffer size in byte
outDataoutput data buffer and its memory is managed by sdk, app can write it but size must not exceed to inOutSize
Returns
whether processed. If processed, return YES and sdk will use outData for later process, otherwise use original data and return NO.

Method Documentation

◆ clearCaches

+ (void) clearCaches

Clears all local cache files.

This operation deletes all cache content generated by the player, including media and metadata.

◆ disableCrashUpload:

+ (void) disableCrashUpload: (BOOL) disable

Sets whether to disable crash stack trace upload.

When enabled, the player will not upload stack traces upon crash.

Parameters
disabletrue to disable crash upload, false to enable it (default)

◆ enableAdaptiveIpDegrade:

+ (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

Parameters
enabletrue to enable adaptive IP degrade, false to disable this feature

◆ enableBufferToLocalCache:

+ (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.

Parameters
enableWhether to enable buffer overflow caching

◆ enableCodecPlugin:valid:

+ (void) enableCodecPlugin: (NSString *) target
valid: (BOOL) valid 

Enables or disables a specific codec plugin.

Parameters
targetThe codec plugin identifier; if empty, the call is ignored
validtrue to enable the plugin, false to disable it

◆ enableEnhancedHttpDns:

+ (void) enableEnhancedHttpDns: (BOOL) enable

Enables enhanced HTTP DNS.

After enabling, note the following:

  • This feature is mutually exclusive with standard HTTP DNS; the latter enabled takes effect
  • A valid enhanced HTTP DNS license is required; otherwise, the feature is inactive
  • Ensure the playback domain is configured and enabled on Alibaba Cloud CDN platform, please refer to: https://www.alibabacloud.com/product/content-delivery-network
Parameters
enableWhether to enable enhanced HTTP DNS. Default is enabled.

◆ enableEnhancedNetworkBalance:

+ (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:

  • This feature is affected by +enableNetworkBalance:; if enableNetworkBalance is disabled, this strategy will also be disabled.
  • Enabling or disabling this strategy does not affect the status of +enableNetworkBalance: itself.
Parameters
enableWhether to enable the enhanced network balancing strategy
See also
+enableNetworkBalance:

◆ enableHttpDns:

+ (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.

Parameters
enableWhether to enable HTTP DNS (this parameter has no effect)
Deprecated
This feature has been removed; do not use

◆ enableHWAduioTempo:

+ (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.

Parameters
enableWhether to enable hardware audio tempo scaling

◆ enableLocalCache:

+ (NSString *) enableLocalCache: (BOOL) enable

Enables or disables local caching.

When enabled, media content is cached to local files.

Disabled by default.

Parameters
enabletrue to enable local cache, false to disable it
Returns
The root directory path for local cache

◆ enableLocalCache:maxBufferMemoryKB:localCacheDir:

+ (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.

Parameters
enabletrue to enable local cache, false to disable it
maxBufferMemoryKBThis parameter is deprecated and has no effect
localCacheDirAbsolute path to the local cache directory

◆ enableNetworkBalance:

+ (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.

Parameters
enableWhether to enable the network balance mechanism
See also
AliMediaLoader

◆ forceAudioRendingFormat:fmt:channels:sample_rate:

+ (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.

Parameters
forceWhether to enable forced format setting
fmtPCM format; currently only "s16" (16-bit signed integer) is supported
channelsPCM channel count; valid range is 1–8
sample_ratePCM sample rate in Hz; valid range is 1–48000

◆ setAdaptiveDecoderGetBackupURLCallback:

+ (void) setAdaptiveDecoderGetBackupURLCallback: (AdaptiveDecoderGetBackupURLCallback) callback

Set the callback to get backup url.

Parameters
callbackThe callback for obtaining a backup URL;

◆ setCacheFileClearConfig:maxCapacityMB:freeStorageMB:

+ (void) setCacheFileClearConfig: (int64_t) expireMin
maxCapacityMB: (int64_t) maxCapacityMB
freeStorageMB: (int64_t) freeStorageMB 

Settings related to automatic clearing of local cache files.

Parameters
expireMinHow long the cache expires: the unit is minute. The default value is 30 days.
maxCapacityMBmaximum 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.
freeStorageMBMinimum 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.

◆ setCacheUrlHashCallback:

+ (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.

Parameters
callbackCustom hash generation callback; set to nil to revert to MD5

◆ setDNSResolve:ip:

+ (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.

Parameters
hostThe host name with port (HTTP default port is 80, HTTPS default port is 443), e.g., player.alicdn.com:443
ipThe corresponding IP address; set to an empty string to clear the mapping

◆ setFairPlayCertID:

+ (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.

Parameters
certIDThe user certificate ID string

◆ setIpResolveType:

+ (void) setIpResolveType: (AVPIpResolveType) type

Sets the IP address type used during DNS resolution.

This setting affects all subsequent DNS resolution behavior.

Parameters
typeThe IP type, defined by the AVPIpResolveType enum

◆ setNetworkDataProcessCallback:

+ (void) setNetworkDataProcessCallback: (NetworkDataProcessCallback) callback

Set the network data callback.

◆ setOption:value:

+ (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.

Parameters
keyThe option key, defined as an integer constant by the SDK,
See also
GlobalOption
Parameters
valueThe corresponding string value for the option
See also
+setOption:valueInt:

◆ setOption:valueInt:

+ (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.

Parameters
keyThe option key, defined as an integer constant by the SDK,
See also
GlobalOption
Parameters
valueIntThe corresponding integer value for the option
See also
+setOption:value:

◆ setUseHttp2:

+ (void) setUseHttp2: (bool) use

Sets whether to use HTTP/2 protocol.

HTTP/2 is enabled by default since SDK version v5.5.0.0.

Parameters
useWhether to enable HTTP/2

The documentation for this class was generated from the following file: