MCPcopy Index your code
hub / github.com/JeffMony/JeffVideoCache

github.com/JeffMony/JeffVideoCache @1.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.0.0 ↗ · + Follow
735 symbols 1,738 edges 70 files 77 documented · 10%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

JeffVideoCache

Better than AndroidVideoCache

参考 中文开发文档

Development Document

  • 1.Realize the pre-loading function without the player
  • 2.Realize the video playback function while caching
  • 3.Realize the M3U8 video playback function while caching
  • 4.Realize the MP4 video playback function while caching
  • 5.Support the player such as exoplayer and ijkplayer
  • 6.Support okhttp library
  • 7.Support the function of continuing to cache to the local after dragging the progress bar
  • 8.Support LRU cleanup rules, you can set the expiration time of the cache

JeffVideoCache Architecture

The core of JeffVideoCache is placed on the client, and the local server and client do a good job of data synchronization

1.How to use
1.1 Initialization

Set JeffVideoCache when the program starts ----> SDK initialization configuration

File saveFile = StorageUtils.getVideoFileDir(this);
if (!saveFile.exists()) {
    saveFile.mkdir();
}
VideoProxyCacheManager.Builder builder = new VideoProxyCacheManager.Builder().
        setFilePath(saveFile.getAbsolutePath()).    //File location
        setConnTimeOut(60 * 1000).                  //Connection timeout
        setReadTimeOut(60 * 1000).                  //Read timeout
        setExpireTime(2 * 24 * 60 * 60 * 1000).     //Expire timeout
        setMaxCacheSize(2 * 1024 * 1024 * 1024);    //Cache Size limit
VideoProxyCacheManager.getInstance().initProxyConfig(builder.build());

Initialization configuration:

  • 1.Set Cache File location
  • 2.Set the Connection timeout
  • 3.Set the Read timeout
  • 4.Set the cache Expire timeout
  • 5.Set the cache size limit
1.2 Build local proxy url
playUrl = ProxyCacheUtils.getProxyUrl(uri.toString(), null, null);

public static String getProxyUrl(String videoUrl, Map<String, String> headers, Map<String, Object> cacheParams)

You can pass in headers, or pass in other additional parameters, according to your own needs

The constructed url is mainly base64 encoded

1.3 Initiate a request
VideoProxyCacheManager.getInstance().startRequestVideoInfo(videoUrl, headers, extraParams);

public void startRequestVideoInfo(String videoUrl, Map<String, String> headers, Map<String, Object> extraParams)
1.4 Set up cache listener
VideoProxyCacheManager.getInstance().addCacheListener(videoUrl, mListener);

mListener:

public interface IVideoCacheListener {

    void onCacheStart(VideoCacheInfo cacheInfo);

    void onCacheProgress(VideoCacheInfo cacheInfo);

    void onCacheError(VideoCacheInfo cacheInfo, int errorCode);

    void onCacheForbidden(VideoCacheInfo cacheInfo);

    void onCacheFinished(VideoCacheInfo cacheInfo);
}
1.5 Set now playing link
VideoProxyCacheManager.getInstance().setPlayingUrlMd5(ProxyCacheUtils.computeMD5(videoUrl));
1.6 Pause cache task
VideoProxyCacheManager.getInstance().pauseCacheTask(mVideoUrl);
1.7 Resume cache task
VideoProxyCacheManager.getInstance().resumeCacheTask(mVideoUrl);
1.8 Drag the video progress bar
long totalDuration = mPlayer.getDuration();
if (totalDuration > 0) {
    float percent = position * 1.0f / totalDuration;
    VideoProxyCacheManager.getInstance().seekToCacheTaskFromClient(mVideoUrl, percent);
}
1.9 stop cache task and release resources
VideoProxyCacheManager.getInstance().stopCacheTask(mVideoUrl);
VideoProxyCacheManager.getInstance().releaseProxyReleases(mVideoUrl);

Extension points exported contracts — how you extend this code

IVideoInfoParsedListener (Interface)
@author jeffmony 解析video info的回调监听 [3 implementers]
videocache/src/main/java/com/jeffmony/videocache/listener/IVideoInfoParsedListener.java
IPlayer (Interface)
(no doc) [3 implementers]
playersdk/src/main/java/com/jeffmony/playersdk/IPlayer.java
IHttpPipelineListener (Interface)
记录http pipeline流水线的时间点 [3 implementers]
videocache/src/main/java/com/jeffmony/videocache/okhttp/IHttpPipelineListener.java
IState (Interface)
@author jeffmony [1 implementers]
videocache/src/main/java/com/jeffmony/videocache/socket/request/IState.java
IMp4CacheThreadListener (Interface)
@author jeffmony 专为Mp4视频的线程下载回调使用 [1 implementers]
videocache/src/main/java/com/jeffmony/videocache/listener/IMp4CacheThreadListener.java
IVideoCacheListener (Interface)
(no doc) [1 implementers]
videocache/src/main/java/com/jeffmony/videocache/listener/IVideoCacheListener.java

Core symbols most depended-on inside this repo

i
called by 47
videocache/src/main/java/com/jeffmony/videocache/utils/LogUtils.java
close
called by 37
videocache/src/main/java/com/jeffmony/videocache/utils/ProxyCacheUtils.java
getEnd
called by 33
videocache/src/main/java/com/jeffmony/videocache/model/VideoRange.java
write
called by 32
videocache/src/main/java/com/jeffmony/videocache/socket/request/ChunkedOutputStream.java
getStart
called by 29
videocache/src/main/java/com/jeffmony/videocache/model/VideoRange.java
w
called by 23
videocache/src/main/java/com/jeffmony/videocache/utils/LogUtils.java
getInstance
called by 22
videocache/src/main/java/com/jeffmony/videocache/VideoProxyCacheManager.java
equals
called by 20
videocache/src/main/java/com/jeffmony/videocache/m3u8/M3U8.java

Shape

Method 650
Class 66
Interface 13
Enum 6

Languages

Java100%

Modules by API surface

videocache/src/main/java/com/jeffmony/videocache/VideoProxyCacheManager.java74 symbols
videocache/src/main/java/com/jeffmony/videocache/m3u8/M3U8Seg.java37 symbols
playersdk/src/main/java/com/jeffmony/playersdk/IPlayer.java32 symbols
videocache/src/main/java/com/jeffmony/videocache/model/VideoCacheInfo.java30 symbols
playersdk/src/main/java/com/jeffmony/playersdk/impl/ExoPlayerImpl.java29 symbols
playersdk/src/main/java/com/jeffmony/playersdk/impl/BasePlayerImpl.java27 symbols
videocache/src/main/java/com/jeffmony/videocache/utils/ProxyCacheUtils.java23 symbols
videocache/src/main/java/com/jeffmony/videocache/okhttp/OkHttpEventListener.java23 symbols
playersdk/src/main/java/com/jeffmony/playersdk/JeffPlayer.java23 symbols
videocache/src/main/java/com/jeffmony/videocache/task/VideoCacheTask.java20 symbols
videocache/src/main/java/com/jeffmony/videocache/task/Mp4CacheTask.java20 symbols
videocache/src/main/java/com/jeffmony/videocache/okhttp/IHttpPipelineListener.java19 symbols

For agents

$ claude mcp add JeffVideoCache \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact