com.aliyun.player

## Class AliPlayerGlobalSettings

- java.lang.Object
- - com.aliyun.player.AliPlayerGlobalSettings

-     public class AliPlayerGlobalSettings
      extends java.lang.Object

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `AliPlayerGlobalSettings.OnGetUrlHashCallback` Get the hash value of the loaded URL, used as the unique id of the URL.
    `static class` | `AliPlayerGlobalSettings.StreamType` audio stream type

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AliPlayerGlobalSettings()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `clearCaches()` Clear all cache files.
    `static void` | `disableCrashUpload(boolean disable)`
    `static void` | `enableBufferToLocalCache(boolean enable)`
    `static void` | `enableHttpDns(boolean enable)` enable httpDNS.
    `static void` | `enableLocalCache(boolean enable, int maxBufferMemoryKB, java.lang.String localCacheDir)` Enable local cache.
    `static void` | `enableNetworkBalance(boolean enable)` enable Network Balance mechanism for control media loader's scheduling automatically.
    `static void` | `forceAudioRendingFormat(boolean force, java.lang.String format, int channels, int sample_rate)` force audio render use the particular format,the value will no effect when the format not supported by device，the out range value will be ignored，and use the default value; and it will affect the pcm data that from audio rending callback, it only can be reset in the same thread, disabled by default.
    `static void` | `loadClass()`
    `static void` | `setAudioStreamType(AliPlayerGlobalSettings.StreamType streamType)` Set audio stream type
    `static void` | `setCacheFileClearConfig(long expireMin, long maxCapacityMB, long freeStorageMB)` Settings related to automatic cleanup of local cache files
    `static void` | `setCacheUrlHashCallback(AliPlayerGlobalSettings.OnGetUrlHashCallback cb)` Sets the hash callback to load the URL.
    `static void` | `setDNSResolve(java.lang.String host, java.lang.String ip)` Set a DNS ip to resolve the host.
    `static void` | `setIPResolveType(IPlayer.IPResolveType type)` set ip resolve type
    `static void` | `setUseHttp2(boolean use)` Set if use http2.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AliPlayerGlobalSettings

          public AliPlayerGlobalSettings()

  - ### Method Detail

    - #### loadClass

          public static void loadClass()

    - #### setDNSResolve

          public static void setDNSResolve(java.lang.String host,
                                           java.lang.String ip)

      Set a DNS ip to resolve the host.
      Parameters:
        `host` - The host. Need to specify the port(http defualt port is 80，https default port is 443). E.g player.alicdn.com:80
        `ip` - The ip address, set as empty string to clear the setting.

    - #### setUseHttp2

          public static void setUseHttp2(boolean use)

      Set if use http2. Default if false.
      Parameters:
        `use` - true：use http2.

    - #### setIPResolveType

          public static void setIPResolveType(IPlayer.IPResolveType type)

      set ip resolve type
      Parameters:
        `type` - See `IPlayer.IPResolveType`

    - #### setAudioStreamType

          public static void setAudioStreamType(AliPlayerGlobalSettings.StreamType streamType)

      Set audio stream type
      Parameters:
        `streamType` - see AliPlayerGlobalSettings.StreamType

    - #### forceAudioRendingFormat

          public static void forceAudioRendingFormat(boolean force,
                                                     java.lang.String format,
                                                     int channels,
                                                     int sample_rate)

      force audio render use the particular format,the value will no effect when the format not supported by device，the out range value will be ignored，and use the default value; and it will affect the pcm data that from audio rending callback, it only can be reset in the same thread, disabled by default.
      Parameters:
        `force` - enable/disable
        `format` - the pcm format, only support s16 for now, signed integer with 16 bits
        `channels` - the pcm channels， available range 1～2
        `sample_rate` - set the pcm sample rate， available range 1～48000

    - #### enableLocalCache

          public static void enableLocalCache(boolean enable,
                                              int maxBufferMemoryKB,
                                              java.lang.String localCacheDir)

      Enable local cache. When enabled, it will be cached in local files.
      Parameters:
        `enable` - true: enables the local cache. false: disable. This function is disabled by default.
        `maxBufferMemoryKB` - Set the maximum memory size for a single source. Unit is KB
        `localCacheDir` - Directory of files cached locally, absolute path

    - #### setCacheFileClearConfig

          public static void setCacheFileClearConfig(long expireMin,
                                                     long maxCapacityMB,
                                                     long freeStorageMB)

      Settings related to automatic cleanup of local cache files
      Parameters:
        `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 20GB. If the total cache size exceeds this size, the cache size is sorted by cacheItem until it is less than or equal to the maximum cache capacity.
        `freeStorageMB` - Minimum free disk capacity: in megabytes (default value: 0). 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.

    - #### clearCaches

          public static void clearCaches()

      Clear all cache files.

    - #### setCacheUrlHashCallback

          public static void setCacheUrlHashCallback(AliPlayerGlobalSettings.OnGetUrlHashCallback cb)

      Sets the hash callback to load the URL. If this parameter is not set, the SDK uses md5 algorithm.
      Parameters:
        `cb` - the hash callback

    - #### enableHttpDns

          public static void enableHttpDns(boolean enable)

      enable httpDNS. Default is disabled.
      Parameters:
        `enable` -

    - #### enableNetworkBalance

          public static void enableNetworkBalance(boolean enable)

      enable Network Balance mechanism for control media loader's scheduling automatically. Default is enabled.
      Parameters:
        `enable` -

    - #### enableBufferToLocalCache

          public static void enableBufferToLocalCache(boolean enable)

      Parameters:
        `enable` -

    - #### disableCrashUpload

          public static void disableCrashUpload(boolean disable)

      Parameters:
        `disable` -