Skip to content

Commit

Permalink
修正一些bug;优化图片加载;(可能是最后一版对4.4以下的支持)
Browse files Browse the repository at this point in the history
  • Loading branch information
q215613905 committed Sep 1, 2023
1 parent 2c7ca19 commit 8b63bf8
Show file tree
Hide file tree
Showing 19 changed files with 62 additions and 43 deletions.
2 changes: 1 addition & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
# 保留我们使用的四大组件,自定义的Application等等这些类不被混淆
# 因为这些子类都有可能被外部调用
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Appliction.**
-keep public class * extends android.app.Application.**
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public Bitmap transform(Bitmap source) {
matrix.postScale(scale, scale);
mBitmapShader.setLocalMatrix(matrix);
}
Bitmap bitmap = Bitmap.createBitmap(viewWidth, viewHeight, Bitmap.Config.ARGB_8888);
Bitmap bitmap = Bitmap.createBitmap(viewWidth, viewHeight, Bitmap.Config.RGB_565);
bitmap.setHasAlpha(true);
Canvas mCanvas = new Canvas(bitmap);
mPaint.setShader(mBitmapShader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ public void onSubtitleChanged(@Nullable final Subtitle subtitle) {
text = text.replaceAll("(?:\\r\\n)", "<br />");
text = text.replaceAll("(?:\\r)", "<br />");
text = text.replaceAll("(?:\\n)", "<br />");
text = text.replaceAll("\\{[\\s\\S]*\\}", "");
text = text.replaceAll("\\\\N", "<br />");
text = text.replaceAll("\\{[\\s\\S]*?\\}", "");
text = text.replaceAll("^.*?,.*?,.*?,.*?,.*?,.*?,.*?,.*?,.*?,", "");
setText(Html.fromHtml(text));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ public void onChanged(AbsXml absXml) {
.override(AutoSizeUtils.mm2px(mContext, 300), AutoSizeUtils.mm2px(mContext, 400))
.roundRadius(AutoSizeUtils.mm2px(mContext, 10), RoundTransformation.RoundType.ALL))
.placeholder(R.drawable.img_loading_placeholder)
.noFade()
.error(R.drawable.img_loading_placeholder)
.into(ivThumb);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,14 +501,15 @@ void playUrl(String url, HashMap<String, String> headers) {
if(autoRetryCount>1 && url.contains(".m3u8")){
url="http://home.jundie.top:666/unBom.php?m3u8="+url;//尝试去bom头再次播放
}
final String[] finalUrl = {url};
final String finalUrl = url;
runOnUiThread(new Runnable() {
@Override
public void run() {
stopParse();
if (mVideoView != null) {
mVideoView.release();
if (finalUrl[0] != null) {
if (finalUrl != null) {
String url =finalUrl;
try {
int playerType = mVodPlayerCfg.getInt("pl");
if (playerType >= 10) {
Expand All @@ -517,28 +518,28 @@ public void run() {
setTip("调用外部播放器" + PlayerHelper.getPlayerName(playerType) + "进行播放", true, false);
boolean callResult = false;
long progress = getSavedProgress(progressKey);
callResult = PlayerHelper.runExternalPlayer(playerType, PlayActivity.this, finalUrl[0], playTitle, playSubtitle, headers, progress);
callResult = PlayerHelper.runExternalPlayer(playerType, PlayActivity.this, url, playTitle, playSubtitle, headers, progress);
setTip("调用外部播放器" + PlayerHelper.getPlayerName(playerType) + (callResult ? "成功" : "失败"), callResult, !callResult);
return;
}
} catch (JSONException e) {
e.printStackTrace();
}
hideTip();
if (finalUrl[0].startsWith("data:application/dash+xml;base64,")) {
if (url.startsWith("data:application/dash+xml;base64,")) {
PlayerHelper.updateCfg(mVideoView, mVodPlayerCfg, 2);
App.getInstance().setDashData(finalUrl[0].split("base64,")[1]);
finalUrl[0] = ControlManager.get().getAddress(true) + "dash/proxy.mpd";
} else if (finalUrl[0].contains(".mpd") || finalUrl[0].contains("type=mpd")) {
App.getInstance().setDashData(url.split("base64,")[1]);
url = ControlManager.get().getAddress(true) + "dash/proxy.mpd";
} else if (url.contains(".mpd") || url.contains("type=mpd")) {
PlayerHelper.updateCfg(mVideoView, mVodPlayerCfg, 2);
} else {
PlayerHelper.updateCfg(mVideoView, mVodPlayerCfg);
}
mVideoView.setProgressKey(progressKey);
if (headers != null) {
mVideoView.setUrl(finalUrl[0], headers);
mVideoView.setUrl(url, headers);
} else {
mVideoView.setUrl(finalUrl[0]);
mVideoView.setUrl(url);
}
mVideoView.start();
mController.resetSpeed();
Expand Down Expand Up @@ -1157,7 +1158,7 @@ public void run() {
LinkedHashMap<String, HashMap<String, String>> jxs = new LinkedHashMap<>();
String extendName = "";
for (ParseBean p : ApiConfig.get().getParseBeanList()) {
HashMap data = new HashMap<String, String>();
HashMap<String, String> data = new HashMap<String, String>();
data.put("url", p.getUrl());
if (p.getUrl().equals(pb.getUrl())) {
extendName = p.getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ protected void convert(BaseViewHolder helper, VodCollect item) {
.override(AutoSizeUtils.mm2px(mContext, 300), AutoSizeUtils.mm2px(mContext, 400))
.roundRadius(AutoSizeUtils.mm2px(mContext, 10), RoundTransformation.RoundType.ALL))
.placeholder(R.drawable.img_loading_placeholder)
.noFade()
.error(R.drawable.img_loading_placeholder)
.into(ivThumb);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ protected void convert(BaseViewHolder helper, Movie.Video item) {
if (!TextUtils.isEmpty(item.pic)) {
Picasso.get()
.load(item.pic)
.transform(new RoundTransformation(MD5.string2MD5(item.pic + "position=" + helper.getLayoutPosition()))
.transform(new RoundTransformation(MD5.string2MD5(item.pic))
.centerCorp(true)
.override(AutoSizeUtils.mm2px(mContext, 300), AutoSizeUtils.mm2px(mContext, 400))
.roundRadius(AutoSizeUtils.mm2px(mContext, 10), RoundTransformation.RoundType.ALL))
.placeholder(R.drawable.img_loading_placeholder)
.noFade()
.error(R.drawable.img_loading_placeholder)
.into(ivThumb);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.github.tvbox.osc.picasso.RoundTransformation;
import com.github.tvbox.osc.util.DefaultConfig;
import com.github.tvbox.osc.util.MD5;
import com.squareup.picasso.MemoryPolicy;
import com.squareup.picasso.Picasso;

import java.util.ArrayList;
Expand Down Expand Up @@ -42,12 +43,13 @@ protected void convert(BaseViewHolder helper, Movie.Video item) {
item.pic=item.pic.trim();
Picasso.get()
.load(DefaultConfig.checkReplaceProxy(item.pic))
.transform(new RoundTransformation(MD5.string2MD5(item.pic + "position=" + helper.getLayoutPosition()))
.transform(new RoundTransformation(MD5.string2MD5(item.pic))
.centerCorp(true)
.override(AutoSizeUtils.mm2px(mContext, 300), AutoSizeUtils.mm2px(mContext, 400))
.override(AutoSizeUtils.mm2px(mContext, 240), AutoSizeUtils.mm2px(mContext, 320))
.roundRadius(AutoSizeUtils.mm2px(mContext, 10), RoundTransformation.RoundType.ALL))
.placeholder(R.drawable.img_loading_placeholder)
.error(R.drawable.img_loading_placeholder)
.noFade()
// .error(R.drawable.img_loading_placeholder)
.into(ivThumb);
} else {
ivThumb.setImageResource(R.drawable.img_loading_placeholder);
Expand Down Expand Up @@ -92,12 +94,13 @@ protected void convert(BaseViewHolder helper, Movie.Video item) {
item.pic=item.pic.trim();
Picasso.get()
.load(DefaultConfig.checkReplaceProxy(item.pic))
.transform(new RoundTransformation(MD5.string2MD5(item.pic + "position=" + helper.getLayoutPosition()))
.transform(new RoundTransformation(MD5.string2MD5(item.pic))
.centerCorp(true)
.override(AutoSizeUtils.mm2px(mContext, 300), AutoSizeUtils.mm2px(mContext, 400))
.override(AutoSizeUtils.mm2px(mContext, 240), AutoSizeUtils.mm2px(mContext, 320))
.roundRadius(AutoSizeUtils.mm2px(mContext, 10), RoundTransformation.RoundType.ALL))
.placeholder(R.drawable.img_loading_placeholder)
.error(R.drawable.img_loading_placeholder)
.noFade()
// .error(R.drawable.img_loading_placeholder)
.into(ivThumb);
} else {
ivThumb.setImageResource(R.drawable.img_loading_placeholder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ protected void convert(BaseViewHolder helper, VodInfo item) {
.override(AutoSizeUtils.mm2px(mContext, 300), AutoSizeUtils.mm2px(mContext, 400))
.roundRadius(AutoSizeUtils.mm2px(mContext, 10), RoundTransformation.RoundType.ALL))
.placeholder(R.drawable.img_loading_placeholder)
.noFade()
.error(R.drawable.img_loading_placeholder)
.into(ivThumb);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,15 @@ protected void convert(BaseViewHolder helper, Movie.Video item) {
ImageView ivThumb = helper.getView(R.id.ivThumb);
//由于部分电视机使用glide报错
if (!TextUtils.isEmpty(item.pic)) {
item.pic=item.pic.trim();
Picasso.get()
.load(DefaultConfig.checkReplaceProxy(item.pic))
.transform(new RoundTransformation(MD5.string2MD5(item.pic + "position=" + helper.getLayoutPosition()))
.transform(new RoundTransformation(MD5.string2MD5(item.pic))
.centerCorp(true)
.override(AutoSizeUtils.mm2px(mContext, 300), AutoSizeUtils.mm2px(mContext, 400))
.roundRadius(AutoSizeUtils.mm2px(mContext, 10), RoundTransformation.RoundType.ALL))
.placeholder(R.drawable.img_loading_placeholder)
.noFade()
.error(R.drawable.img_loading_placeholder)
.into(ivThumb);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ protected void convert(BaseViewHolder helper, Movie.Video item) {
if (!TextUtils.isEmpty(item.pic)) {
Picasso.get()
.load(item.pic)
.transform(new RoundTransformation(MD5.string2MD5(item.pic + "position=" + helper.getLayoutPosition()))
.transform(new RoundTransformation(MD5.string2MD5(item.pic))
.centerCorp(true)
.override(AutoSizeUtils.mm2px(mContext, 300), AutoSizeUtils.mm2px(mContext, 400))
.roundRadius(AutoSizeUtils.mm2px(mContext, 10), RoundTransformation.RoundType.ALL))
.placeholder(R.drawable.img_loading_placeholder)
.noFade()
.error(R.drawable.img_loading_placeholder)
.into(ivThumb);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,14 +514,15 @@ void playUrl(String url, HashMap<String, String> headers) {
}
if (mActivity == null) return;
if (!isAdded()) return;
final String[] finalUrl = {url};
final String finalUrl = url;
requireActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
stopParse();
if (mVideoView != null) {
mVideoView.release();
if (finalUrl[0] != null) {
if (finalUrl != null) {
String url = finalUrl;
try {
int playerType = mVodPlayerCfg.getInt("pl");
if (playerType >= 10) {
Expand All @@ -530,28 +531,28 @@ public void run() {
setTip("调用外部播放器" + PlayerHelper.getPlayerName(playerType) + "进行播放", true, false);
boolean callResult = false;
long progress = getSavedProgress(progressKey);
callResult = PlayerHelper.runExternalPlayer(playerType, requireActivity(), finalUrl[0], playTitle, playSubtitle, headers, progress);
callResult = PlayerHelper.runExternalPlayer(playerType, requireActivity(), url, playTitle, playSubtitle, headers, progress);
setTip("调用外部播放器" + PlayerHelper.getPlayerName(playerType) + (callResult ? "成功" : "失败"), callResult, !callResult);
return;
}
} catch (JSONException e) {
e.printStackTrace();
}
hideTip();
if (finalUrl[0].startsWith("data:application/dash+xml;base64,")) {
if (url.startsWith("data:application/dash+xml;base64,")) {
PlayerHelper.updateCfg(mVideoView, mVodPlayerCfg, 2);
App.getInstance().setDashData(finalUrl[0].split("base64,")[1]);
finalUrl[0] = ControlManager.get().getAddress(true) + "dash/proxy.mpd";
} else if (finalUrl[0].contains(".mpd") || finalUrl[0].contains("type=mpd")) {
App.getInstance().setDashData(url.split("base64,")[1]);
url = ControlManager.get().getAddress(true) + "dash/proxy.mpd";
} else if (url.contains(".mpd") || url.contains("type=mpd")) {
PlayerHelper.updateCfg(mVideoView, mVodPlayerCfg, 2);
} else {
PlayerHelper.updateCfg(mVideoView, mVodPlayerCfg);
}
mVideoView.setProgressKey(progressKey);
if (headers != null) {
mVideoView.setUrl(finalUrl[0], headers);
mVideoView.setUrl(url, headers);
} else {
mVideoView.setUrl(finalUrl[0]);
mVideoView.setUrl(url);
}
mVideoView.start();
mController.resetSpeed();
Expand Down Expand Up @@ -1185,7 +1186,7 @@ public void run() {
LinkedHashMap<String, HashMap<String, String>> jxs = new LinkedHashMap<>();
String extendName = "";
for (ParseBean p : ApiConfig.get().getParseBeanList()) {
HashMap data = new HashMap<String, String>();
HashMap<String, String> data = new HashMap<String, String>();
data.put("url", p.getUrl());
if (p.getUrl().equals(pb.getUrl())) {
extendName = p.getName();
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/github/tvbox/osc/util/OkGoHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import java.io.File;
import java.security.cert.CertificateException;
import java.util.ArrayList;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ public static void parse(Context context, Movie.Video.UrlBean urlBean, ThunderCa
torrentFileInfoArrayList=new ArrayList<>();
playList=new ArrayList<>();
ed2kList=new ArrayList<>();
ArrayList<String> jxUrls=new ArrayList<>();
Map<Integer, String> urlMap = new HashMap<>();
threadPool.execute(new Runnable() {
@Override
Expand All @@ -116,7 +115,6 @@ public void run() {
for (Movie.Video.UrlBean.UrlInfo.InfoBean infoBean : urlInfo.beanList) {
boolean isParse=false;
url=infoBean.url;
// if(jxUrls.contains(url))continue;
if (isMagnet(url) || isThunder(url) || isTorrent(url)) {
if(isThunder(url) )url=XLDownloadManager.getInstance().parserThunderUrl(url);
String link = isThunder(url) ? XLDownloadManager.getInstance().parserThunderUrl(url) : url;
Expand All @@ -141,7 +139,7 @@ public void run() {
if (currentTask <= 0) {
continue;
}
int count = 15;
int count = 30;
outerLoop:
while (true) {
count--;
Expand All @@ -160,13 +158,12 @@ public void run() {
TorrentFileInfo[] mSubFileInfo = torrentInfo.mSubFileInfo;
if (mSubFileInfo != null) {
for (TorrentFileInfo sub : mSubFileInfo) {
if (isMedia(sub.mFileName)) {
if (isMedia(sub.mFileName) && sub.mFileSize > 1048576L * 30) {
sub.torrentPath = cache.getAbsolutePath();
playList.add(sub.mFileName + "$tvbox-torrent:" + torrentFileInfoArrayList.size());
torrentFileInfoArrayList.add(sub);
}
}
jxUrls.add(url);
isParse=true;
break outerLoop;
}
Expand All @@ -183,7 +180,7 @@ public void run() {
}
}
try {
Thread.sleep(200);
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
Expand Down
Loading

2 comments on commit 8b63bf8

@fenger2022
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你好,\app\src\main\java\com\github\tvbox\osc\player\controller\VodController.java 这个文件0821版本之后新增的代码疑似有点问题,我这里显示不出来视频下方的播放控制和解析线路菜单,这个文件换成0821的后就正常显示了

@1006727758
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

播放阿里云高分辨率的会卡,能不能修复

Please sign in to comment.