• Stars
    star
    269
  • Rank 152,662 (Top 4 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created almost 5 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The library is working for downloading video while playing the video, the video contains M3U8/MP4

MediaSDK

The library is working for downloading video while playing the video, the video contains M3U8/MP4

Developer documentation is here, Click it

You can refer to the technical documentation:https://www.jianshu.com/p/27085da32a35

Use the library:

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}

dependencies {
        implementation 'com.github.JeffMony:MediaSDK:2.0.0'
}

The Core functions of the project

  • Cache management, LRU
  • Video downloading management
  • Local proxy management
  • Display downloading speed
  • Display the video cache's size
  • Support the video's downloading while playing the video, M3U8/MP4 video

The project's architecture is as follows:

Developer documentation

1.Application->onCreate(...)

File file = LocalProxyUtils.getVideoCacheDir(this);
if (!file.exists()) {
    file.mkdir();
}
LocalProxyConfig config = new VideoDownloadManager.Build(this)
    .setCacheRoot(file)
    .setUrlRedirect(false)
    .setTimeOut(DownloadConstants.READ_TIMEOUT, DownloadConstants.CONN_TIMEOUT, DownloadConstants.SOCKET_TIMEOUT)
    .setConcurrentCount(DownloadConstants.CONCURRENT_COUNT)
    .setIgnoreAllCertErrors(true)
    .buildConfig();
VideoDownloadManager.getInstance().initConfig(config);

1.setCacheRoot The cache path; 2.setUrlRedirect Support request's redirect; 3.setCacheSize Set cache size; 4.setTimeOut Set request's timeout; 5.setPort Set the local proxy server's port; 6.setIgnoreAllCertErrors Support the certificate;

2.The local proxy server's switch

PlayerAttributes attributes = new PlayerAttributes();
attributes.setUseLocalProxy(mUseLocalProxy);

3.Set the listener

mPlayer.setOnLocalProxyCacheListener(mOnLocalProxyCacheListener);
mPlayer.startLocalProxy(mUrl, null);

private IPlayer.OnLocalProxyCacheListener mOnLocalProxyCacheListener = new IPlayer.OnLocalProxyCacheListener() {
    @Override
    public void onCacheReady(IPlayer mp, String proxyUrl) {
        LogUtils.w("onCacheReady proxyUrl = " + proxyUrl);
        Uri uri = Uri.parse(proxyUrl);
        try {
            mPlayer.setDataSource(PlayerActivity.this, uri);
        } catch (IOException e) {
            e.printStackTrace();
            return;
        }
        mPlayer.setSurface(mSurface);
        mPlayer.setOnPreparedListener(mPreparedListener);
        mPlayer.setOnVideoSizeChangedListener(mVideoSizeChangeListener);
        mPlayer.prepareAsync();
    }

    @Override
    public void onCacheProgressChanged(IPlayer mp, int percent, long cachedSize) {
        LogUtils.w("onCacheProgressChanged percent = " + percent);
        mPercent = percent;
    }

    @Override
    public void onCacheSpeedChanged(String url, float cacheSpeed) {
        if (mPlayer != null && mPlayer.get() != null) {
            mPlayer.get().notifyProxyCacheSpeed(cacheSpeed);
        }
    }

    @Override
    public void onCacheFinished(String url) {
        LogUtils.i("onCacheFinished url="+url + ", player="+this);
        mIsCompleteCached = true;
    }

    @Override
    public void onCacheForbidden(String url) {
        LogUtils.w("onCacheForbidden url="+url+", player="+this);
        mUseLocalProxy = false;
        if (mPlayer != null && mPlayer.get() != null) {
            mPlayer.get().notifyProxyCacheForbidden(url);
        }
    }

    @Override
    public void onCacheFailed(String url, Exception e) {
        LogUtils.w("onCacheFailed , player="+this);
        pauseProxyCacheTask(PROXY_CACHE_EXCEPTION);
    }
};

demo:

More Repositories

1

VideoDownloader

支持下载队列,支持M3U8视频、MP4视频等,支持M3U8合并为MP4视频。
Java
458
star
2

JeffVideoCache

Better than AndroidVideoCache, it supports M3U8 and MP4
Java
296
star
3

PlayerSDK

提供一个高效的播放器库,播放相关的优化和功能都会在这个项目中完成
Java
147
star
4

MediaEditSDK

使用android原生的MediaExtractor,MediaCodec和OpenGL ES对视频进行编辑, 裁剪,滤镜, 特效等.
Java
77
star
5

MediaParserTools

解析mp4 flv ts h264 ts 文件的一整套工具
38
star
6

AV_Library

从0开始教你做一款剪映APP
34
star
7

VideoCapCut

全面的商业化音视频编辑软件
Java
32
star
8

AndroidFFmpegCompile

编译Android 平台上 ffmpeg,openssl,x264 库
C
25
star
9

JeffFFmpegDemo

C
24
star
10

AV_Knowledge

专注音视频面试题汇总
C
23
star
11

JeffLiveSDK

Android 平台下的直播SDK(1.实现opengl 滤镜;2.实现H264视频编码,AAC音频编码3.实现FLV封包;4.实现RTMP推流)
Java
16
star
12

VideoApplication

1.分离音频、视频 2.裁剪音频、视频 3.音频、视频合成功能 4.两个或者多个视频拼接 5.取出视频中关键帧 6.生成快慢视频 7.生成倒播的视频
Java
16
star
13

JeffVideoLib

M3U8视频合并为MP4视频专用库,已经尽量裁减优化,减少包大小,只保留这个功能
C++
15
star
14

Laker

视频播放器外接的渲染工具,使用opengl渲染视频,实现视频翻转、各种滤镜、调整亮度、色温、对比度、饱和度、锐度、添加水印等等
C++
14
star
15

VLCAndroidDemo

实现Android VLC 库的播放调用,实现VLC的主要接口
Java
10
star
16

OpenCamera

实现android-camera和camera2的功能,可以3A调整,尽可能利用系统api爆发的能量
Java
10
star
17

JeffAudioPlayer

从0开始实现一款音频播放器
C
9
star
18

AV_Book

音视频开发书籍汇总
8
star
19

CustomPlayer

使用FFmpeg OpenGL-ES OpenSL-ES 实现一个简单的视频播放器
C
7
star
20

AVInterview

音视频/Android面试题集合
C
7
star
21

CameraApp

Camera1 Camera2 CameraX实现拍照、录视频、剪视频功能
Java
6
star
22

M3U8ParserTools

python 实现 M3U8文件的解析功能
Python
6
star
23

GifSDK

实现将若干张图片变成一个gif图
Java
6
star
24

AudioSDK

音频处理库
C
4
star
25

DexMerge

实现dex合并的功能
Java
4
star
26

androidEnhance

Android 平台framework、chromium、camera、音视频相关技术博客汇总
3
star
27

MessageQueue

c++ message queue
C++
3
star
28

Algorithm_Interview

算法知识总结
Java
3
star
29

FFmpegDemo

代码实现FFmpeg基本功能
C
2
star
30

JMediaCodec

实现MediaCodec并行编码和解码的工作
Java
2
star
31

MediaCache

C++
2
star
32

OpenGLDemo

提供了OpenGL ES 相关的几个demo,可以学习OpenGL ES基本功能
Java
2
star
33

JeffMP4SDK

实现MP4视频的拼接,h264转MP4视频,ts合并为MP4视频
Java
2
star
34

JeffMony

1
star
35

libwebp-android

libwebp library with android platform
CMake
1
star
36

CustomCameraFilter

Camera OpenGLES implements custom filters
Java
1
star
37

SPS-PPS-Parser

1
star
38

FutureHouse

1
star
39

JeffCamera

C
1
star