This commit is contained in:
Gangphon 2024-05-11 21:12:39 +08:00
parent bd5851a5a3
commit db4c46e7e9
8 changed files with 63 additions and 18 deletions

View File

@ -11,7 +11,7 @@ android {
minSdk 21
targetSdk 34
versionCode 1
versionName "2.1"
versionName "2.1.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

View File

@ -0,0 +1,10 @@
package com.xixun.command.reply;
import java.io.Serializable;
public abstract class ReplyBase implements Serializable{
private static final long serialVersionUID = -3630726876519388513L;
public String commandId;
}

View File

@ -0,0 +1,18 @@
package com.xixun.command.reply;
public class TaskProgressReply extends ReplyBase {
private static final long serialVersionUID = 6264049742389542806L;
public int percent;
public String taskItemId;
public int speed;
public int remainingSeconds;
public TaskProgressReply(String commandId, String taskItemId, int percent, int sp, int rs) {
this.commandId = commandId;
this.taskItemId = taskItemId;
this.percent = percent;
this.speed = sp;
this.remainingSeconds = rs;
}
}

View File

@ -10,13 +10,14 @@ import android.view.View;
public class BackView extends View {
public Bitmap img, cosImg;
private Bitmap img;
Bitmap cosImg;
Rect rect = new Rect();
public BackView(Context context, int width, int height) {
super(context);
img = BitmapFactory.decodeResource(context.getResources(), R.drawable.back);
cosImg = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/XixunPlayer/background");
img = BitmapFactory.decodeResource(context.getResources(), R.drawable.back, Util.noScaled);
cosImg = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/XixunPlayer/background", Util.noScaled);
rect.right = width;
rect.bottom = height;
}

View File

@ -7,12 +7,12 @@ import android.graphics.BitmapFactory;
import android.os.IBinder;
import android.os.RemoteException;
import com.xixun.command.reply.TaskProgressReply;
import com.xixun.util.PlayerInfo;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Base64;
@ -181,24 +181,35 @@ public class Server extends Service {
Util.printStackTrace(e);
}
cnt++;
if(notificationURL!=null && cnt!=needDown.srcs.size()) {
try {
new URLConn(notificationURL).timeout(5000).writeJson(new JSMap(
"commandId", finalCommandId,
"taskItemId", needDown.prog,
"progress", cnt*100/needDown.srcs.size()).toStr()).read();
} catch (IOException e) {
Util.printStackTrace(e);
var progress = cnt*100/needDown.srcs.size();
if(cnt != needDown.srcs.size()) {
if(notificationURL==null) {
var intent = new Intent("xixun.intent.action.REPLY");
intent.putExtra("reply", new TaskProgressReply(finalCommandId, needDown.prog, progress, 500, 3));
MainActivity.ins.sendBroadcast(intent);
} else {
try {
new URLConn(notificationURL).timeout(5000).writeJson(new JSMap(
"commandId", finalCommandId,
"taskItemId", needDown.prog,
"progress", progress).toStr()).read();
} catch (Exception e) {
Util.printStackTrace(e);
}
}
}
}
if(notificationURL!=null) {
if(notificationURL==null) {
var intent = new Intent("xixun.intent.action.REPLY");
intent.putExtra("reply", new TaskProgressReply(finalCommandId, needDown.prog, 100, 400, 0));
MainActivity.ins.sendBroadcast(intent);
} else {
try {
new URLConn(notificationURL).timeout(5000).writeJson(new JSMap(
"commandId", finalCommandId,
"taskItemId", needDown.prog,
"progress", 100).toStr()).read();
} catch (IOException e) {
} catch (Exception e) {
Util.printStackTrace(e);
}
}
@ -240,7 +251,7 @@ public class Server extends Service {
fout.close();
}
MainActivity.ins.runOnUiThread(() -> {
MainActivity.ins.backView.cosImg = url==null ? null : BitmapFactory.decodeFile(Util.backImgFile);
MainActivity.ins.backView.cosImg = url==null ? null : BitmapFactory.decodeFile(Util.backImgFile, Util.noScaled);
MainActivity.ins.backView.invalidate();
});
return new JSMap(

View File

@ -86,7 +86,7 @@ public class SocketThread extends Thread {
fout.getFD().sync();
fout.close();
main.runOnUiThread(() -> {
main.backView.cosImg = BitmapFactory.decodeFile(Util.backImgFile);
main.backView.cosImg = BitmapFactory.decodeFile(Util.backImgFile, Util.noScaled);
main.backView.invalidate();
});
} else if("imgFileEnd".equals(_type)) {

View File

@ -46,7 +46,7 @@ public class SrcVideo extends TextureView implements TextureView.SurfaceTextureL
}
void initIjk() {
ijkPlayer = new IjkMediaPlayer();
ijkPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec-avc", 1);
//ijkPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec-avc", 1);
ijkPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "start-on-prepared", 0);
ijkPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "analyzeduration", 1);
ijkPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_CODEC, "skip_loop_filter", 48);

View File

@ -1,6 +1,7 @@
package com.xixun.xixunplayer;
import android.content.Context;
import android.graphics.BitmapFactory;
import android.os.Environment;
import android.os.StatFs;
import android.view.Gravity;
@ -25,6 +26,10 @@ public class Util {
public static int screenWidth, screenHeight;
public static boolean isScreenOn;
public static final BitmapFactory.Options noScaled = new BitmapFactory.Options();
static {
noScaled.inScaled = false;
}
public static final Vector<SocketThread> socketThreads = new Vector<>();
public static final HashMap<Integer, String[]> stateDescs = new HashMap<>();
static {