Skip to content

Commit

Permalink
修改缓存与播放器的加载模式
Browse files Browse the repository at this point in the history
  • Loading branch information
CarGuoSmall committed Aug 30, 2018
1 parent 1ce84e3 commit bad6fb6
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 20 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ dependencies {
implementation androidDependencies.support_v4
implementation androidDependencies.design

//implementation project(':gsyVideoPlayer')
implementation project(':gsyVideoPlayer')

implementation dataDependencies.okhttpUtil
implementation dataDependencies.okhttp
Expand All @@ -89,7 +89,7 @@ dependencies {


//jcenter
implementation "com.shuyu:GSYVideoPlayer:$gsyVideoVersion"
//implementation "com.shuyu:GSYVideoPlayer:$gsyVideoVersion"

//implementation "com.shuyu:gsyVideoPlayer-java:$gsyVideoVersion'

Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/com/example/gsyvideoplayer/GSYApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ public void onCreate() {
//GSYVideoType.enableMediaCodec();
//GSYVideoType.enableMediaCodecTexture();

//PlayerFactory.setPlayManager(new Exo2PlayerManager());//EXO模式
//PlayerFactory.setPlayManager(new SystemPlayerManager());//系统模式
//PlayerFactory.setPlayManager(new IjkPlayerManager());//ijk模式
PlayerFactory.setPlayManager(Exo2PlayerManager.class);//EXO模式
//PlayerFactory.setPlayManager(SystemPlayerManager.class);//系统模式
//PlayerFactory.setPlayManager(IjkPlayerManager.class);//ijk模式

//CacheFactory.setCacheManager(new ExoPlayerCacheManager());//exo缓存模式,支持m3u8,只支持exo
//CacheFactory.setCacheManager(new ProxyCacheManager());//代理缓存模式,支持所有模式,不支持m3u8等
CacheFactory.setCacheManager(ExoPlayerCacheManager.class);//exo缓存模式,支持m3u8,只支持exo
//CacheFactory.setCacheManager(ProxyCacheManager.class);//代理缓存模式,支持所有模式,不支持m3u8等

//GSYVideoType.setShowType(GSYVideoType.SCREEN_MATCH_FULL);
//GSYVideoType.setShowType(GSYVideoType.SCREEN_TYPE_FULL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ public void clearDefaultCache(Context context, @Nullable File cacheDir, @Nullabl
if (cacheManager != null) {
cacheManager.clearCache(context, cacheDir, url);
} else {
getCacheManager().clearCache(context, cacheDir, url);
if(getCacheManager() != null) {
getCacheManager().clearCache(context, cacheDir, url);
}
}
}

Expand Down Expand Up @@ -403,7 +405,10 @@ public boolean isCacheFile() {
*/
@Override
public boolean cachePreview(Context context, File cacheDir, String url) {
return getCacheManager().cachePreview(context, cacheDir, url);
if(getCacheManager() != null) {
return getCacheManager().cachePreview(context, cacheDir, url);
}
return false;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,23 @@
*/
public class CacheFactory {

private static ICacheManager sICacheManager;
private static Class<? extends ICacheManager> sICacheManager;

public static void setCacheManager(ICacheManager cacheManager) {
public static void setCacheManager(Class<? extends ICacheManager> cacheManager) {
sICacheManager = cacheManager;
}

public static ICacheManager getCacheManager() {
if (sICacheManager == null) {
sICacheManager = new ProxyCacheManager();
sICacheManager = ProxyCacheManager.class;
}
return sICacheManager;
try {
return sICacheManager.newInstance();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,24 @@
*/
public class PlayerFactory {

private static IPlayerManager sPlayerManager;
private static Class<? extends IPlayerManager> sPlayerManager;

public static void setPlayManager(IPlayerManager playManager) {
public static void setPlayManager(Class<? extends IPlayerManager> playManager) {
sPlayerManager = playManager;
}

public static IPlayerManager getPlayManager() {
if(sPlayerManager == null) {
sPlayerManager = new IjkPlayerManager();
if (sPlayerManager == null) {
sPlayerManager = IjkPlayerManager.class;
}
return sPlayerManager;
try {
return sPlayerManager.newInstance();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return null;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.shuyu.gsyvideoplayer.render.view;

/**
* Created by guoshuyu
* Date: 2018-08-30
*/
public class RenderFactory {
}
4 changes: 2 additions & 2 deletions gsyVideoPlayer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

//api project(':gsyVideoPlayer-java')
api project(':gsyVideoPlayer-java')
//api project(':gsyVideoPlayer-exo_player2')
//api project(':gsyVideoPlayer-armv5')
//api project(':gsyVideoPlayer-armv7a')
Expand All @@ -44,7 +44,7 @@ dependencies {

//api "com.shuyu:GSYVideoPlayer:$gsyVideoVersion"

api "com.shuyu:gsyVideoPlayer-java:$gsyVideoVersion"
//api "com.shuyu:gsyVideoPlayer-java:$gsyVideoVersion"
api "com.shuyu:GSYVideoPlayer-exo2:$gsyVideoVersion"
api "com.shuyu:gsyVideoPlayer-armv5:$gsyVideoVersion"
api "com.shuyu:gsyVideoPlayer-armv7a:$gsyVideoVersion"
Expand Down

0 comments on commit bad6fb6

Please sign in to comment.