翰林优商.apk(点击下载) / KSVodPlayerCommonInitConfig.java
package com.kwai.video.ksvodplayerkit;
import android.content.Context;
import android.text.TextUtils;
import com.kuaishou.aegon.Aegon;
import com.kwai.video.cache.AwesomeCache;
import com.kwai.video.cache.AwesomeCacheInitConfig;
import com.kwai.video.cache.AwesomeCacheSoLoader;
import com.kwai.video.ksvodplayerkit.Logger.KSVodLogger;
import com.kwai.video.ksvodplayerkit.prefetcher.KSPrefetcher;
import com.kwai.video.player.KsMediaPlayer;
import com.kwai.video.player.KsMediaPlayerInitConfig;
import com.kwai.video.player.KsSoLoader;
import com.kwai.video.player.kwai_player.KwaiMediaPlayer;
import java.io.File;
public class KSVodPlayerCommonInitConfig {
private static final String TAG = "KSVodPlayerCommonInitConfig";
private static boolean sEnableLog = true;
private static volatile VodSoLoader sInjectedSoLoader;
public static void clearCache() {
AwesomeCache.clearCacheDir();
KSVodPlayStatManager.getInstance().clearCacheStatus();
}
public static void enableLog(boolean z) {
sEnableLog = z;
int i = z ? 4 : 8;
KwaiMediaPlayer.native_setLogLevel(i);
KwaiMediaPlayer.native_setKwaiLogLevel(i);
}
public static boolean enableLog() {
return sEnableLog;
}
public static String getCachePath(Context context) {
File externalCacheDir = context.getExternalCacheDir();
if (externalCacheDir != null) {
return externalCacheDir.getAbsolutePath() + File.separator + "ACache";
}
return context.getDir("vodCache", 0) + File.separator + "ACache";
}
public static void init(Context context) {
init(context, getCachePath(context));
}
public static void init(Context context, String str) {
init(context, str, null);
}
public static void init(Context context, String str, String str2) {
AwesomeCacheInitConfig.setSoLoader(new AwesomeCacheSoLoader() {
/* class com.kwai.video.ksvodplayerkit.KSVodPlayerCommonInitConfig.AnonymousClass1 */
@Override // com.kwai.video.cache.AwesomeCacheSoLoader
public final void loadLibrary(String str) {
if (KSVodPlayerCommonInitConfig.sInjectedSoLoader != null) {
KSVodPlayerCommonInitConfig.sInjectedSoLoader.loadLibrary(str);
return;
}
KSVodLogger.w(KSVodPlayerCommonInitConfig.TAG, "WARNING! AwesomeCacheSoLoader is using System.loadLibrary");
System.loadLibrary(str);
}
});
if (TextUtils.isEmpty(str)) {
getCachePath(context);
}
AwesomeCacheInitConfig.init(context);
KsMediaPlayerInitConfig.setSoLoader(new KsSoLoader() {
/* class com.kwai.video.ksvodplayerkit.KSVodPlayerCommonInitConfig.AnonymousClass2 */
@Override // com.kwai.video.player.KsSoLoader
public final void loadLibrary(String str) {
if (KSVodPlayerCommonInitConfig.sInjectedSoLoader != null) {
KSVodPlayerCommonInitConfig.sInjectedSoLoader.loadLibrary(str);
return;
}
KSVodLogger.w(KSVodPlayerCommonInitConfig.TAG, "WARNING! AwesomeCacheSoLoader is using System.loadLibrary");
System.loadLibrary(str);
}
});
KsMediaPlayerInitConfig.init(context);
KsMediaPlayer.native_profileBegin("libkwaiplayer.so");
KwaiMediaPlayer.native_setLogLevel(4);
KwaiMediaPlayer.native_setKwaiLogLevel(4);
if (!TextUtils.isEmpty(str2)) {
initAegon(context, str2);
}
KSPrefetcher.getInstance().init(context);
}
public static void initAegon(Context context, String str) {
if (str != null) {
Aegon.initialize(context, str, context.getFilesDir().getAbsolutePath(), new Aegon.LibraryLoader() {
/* class com.kwai.video.ksvodplayerkit.KSVodPlayerCommonInitConfig.AnonymousClass3 */
@Override // com.kuaishou.aegon.Aegon.LibraryLoader
public final void loadLibrary(String str) {
if (KSVodPlayerCommonInitConfig.sInjectedSoLoader != null) {
KSVodPlayerCommonInitConfig.sInjectedSoLoader.loadLibrary(str);
return;
}
KSVodLogger.w(KSVodPlayerCommonInitConfig.TAG, "WARNING! Aegon is using System.loadLibrary");
System.loadLibrary(str);
}
});
Aegon.getCronetEngine();
Aegon.setDebug(false);
}
}
public static boolean isSoLoadCompleted() {
return KsMediaPlayerInitConfig.isSoLibInited();
}
public static void setSoLoader(VodSoLoader vodSoLoader) {
sInjectedSoLoader = vodSoLoader;
}
public static void updatePlayerConfig(String str) {
KSVodPlayerConfig.get().setConfigJsonStr(str);
}
}