IMediaPlayerCacheManager

This class provides methods to manage cached media files.

EnableAutoRemoveCache

Sets whether to delete cached media files automatically.

public abstract int EnableAutoRemoveCache(bool enable);

Details

If you enable this function to remove cached media files automatically, when the cached media files exceed either the number or size limit you set, the SDK automatically deletes the least recently used cache file.

Parameters

enable
Whether to enable the SDK to delete cached media files automatically:
  • true: Delete cached media files automatically.
  • false: (Default) Do not delete cached media files automatically.

Returns

GetCacheDir

Gets the storage path of the cached media files.

public abstract int GetCacheDir(out string path, int length);

Details

If you have not called the SetCacheDir method to set the storage path for the media files to be cached before calling this method, you get the default storage path used by the SDK.

Parameters

path
An output parameter; the storage path for the media file to be cached.
length
An input parameter; the maximum length of the cache file storage path string. Fill in according to the cache file storage path string you obtained from path.

Returns

GetCacheFileCount

Gets the number of media files that are cached.

public abstract int GetCacheFileCount();

Returns

  • ≥ 0: The call succeeds and returns the number of media files that are cached.
  • < 0: Failure. See MEDIA_PLAYER_REASON.

GetMaxCacheFileCount

Gets the maximum number of media files that can be cached.

public abstract int GetMaxCacheFileCount();

Details

By default, the maximum number of media files that can be cached is 1,000.

Returns

  • > 0: The call succeeds and returns the maximum number of media files that can be cached.
  • < 0: Failure. See MEDIA_PLAYER_REASON.

GetMaxCacheFileSize

Gets the maximum size of the aggregate storage space for cached media files.

public abstract Int64 GetMaxCacheFileSize();

Details

By default, the maximum size of the aggregate storage space for cached media files is 1 GB. You can call the SetMaxCacheFileSize method to set the limit according to your scenarios.

Returns

  • > 0: The call succeeds and returns the maximum size (in bytes) of the aggregate storage space for cached media files.
  • < 0: Failure. See MEDIA_PLAYER_REASON.

RemoveAllCaches

Deletes all cached media files in the media player.

 public abstract int RemoveAllCaches();

Details

Note:

The cached media file currently being played will not be deleted.

Returns

RemoveCacheByUri

Deletes a cached media file.

public abstract int RemoveCacheByUri(string uri) ;

Details

Note:

The cached media file currently being played will not be deleted.

Parameters

uri
The URI (Uniform Resource Identifier) of the media file to be deleted.

Returns

RemoveOldCache

Deletes a cached media file that is the least recently used.

public abstract int RemoveOldCache();

Details

You can call this method to delete a cached media file when the storage space for the cached files is about to reach its limit. After you call this method, the SDK deletes the cached media file that is least used.

Note:

The cached media file currently being played will not be deleted.

Returns

SetCacheDir

Sets the storage path for the media files that you want to cache.

public abstract int SetCacheDir(string path) ;

Details

Note:

Make sure IRtcEngine is initialized before you call this method.

Parameters

path
The absolute path of the media files to be cached. Ensure that the directory for the media files exists and is writable.

Returns

SetMaxCacheFileCount

Sets the maximum number of media files that can be cached.

public abstract int SetMaxCacheFileCount(int count);

Parameters

count
The maximum number of media files that can be cached. The default value is 1,000.

Returns

SetMaxCacheFileSize

Sets the maximum size of the aggregate storage space for cached media files.

public abstract int SetMaxCacheFileSize(Int64 cacheSize);

Parameters

cacheSize
The maximum size (bytes) of the aggregate storage space for cached media files. The default value is 1 GB.

Returns