From 586583ddfdb5b086ef5a814e60e42331a6f89635 Mon Sep 17 00:00:00 2001 From: Gangphon Date: Sat, 24 Aug 2024 17:05:31 +0800 Subject: [PATCH] player --- .../java/com/xixun/xixunplayer/BackView.java | 2 +- .../com/xixun/xixunplayer/MainActivity.java | 39 ++++++++++--------- .../main/java/com/xixun/xixunplayer/Prog.java | 23 +++++++---- .../java/com/xixun/xixunplayer/SrcSensor.java | 14 +++---- 4 files changed, 42 insertions(+), 36 deletions(-) diff --git a/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/BackView.java b/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/BackView.java index d8a129c..f4fd8a4 100644 --- a/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/BackView.java +++ b/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/BackView.java @@ -17,7 +17,7 @@ public class BackView extends View { public BackView(Context context, int width, int height) { super(context); img = BitmapFactory.decodeResource(context.getResources(), R.drawable.back, Util.noScaled); - cosImg = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/XixunPlayer/background", Util.noScaled); + cosImg = BitmapFactory.decodeFile(Util.backImgFile, Util.noScaled); rect.right = width; rect.bottom = height; } diff --git a/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/MainActivity.java b/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/MainActivity.java index 2be2ed2..6afa3b9 100644 --- a/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/MainActivity.java +++ b/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/MainActivity.java @@ -139,7 +139,7 @@ public class MainActivity extends Activity implements Choreographer.FrameCallbac if(requestCode==999 && grantResults.length > 0 && grantResults[0]==PackageManager.PERMISSION_GRANTED && backView==null) init(); } - ConnService connService; + ConnService serviXy; @SuppressLint("UnspecifiedRegisterReceiverFlag") public void init() { @@ -156,12 +156,12 @@ public class MainActivity extends Activity implements Choreographer.FrameCallbac var cardConn = new ServiceConnection() { public void onServiceDisconnected(ComponentName name) { - Util.println("Disconnected cardsystem aidl service"); + Util.println("<-<- AIDL Service cardsystem Disconnected"); } public void onServiceConnected(ComponentName name, IBinder iBinder) { unbindService(this); - Util.println("Bind cardsystem aidl service success"); + Util.println("->-> AIDL Service cardsystem aidl service Connected"); var service = CardService.Stub.asInterface(iBinder); try { Util.isScreenOn = service.isScreenOpen(); @@ -182,17 +182,17 @@ public class MainActivity extends Activity implements Choreographer.FrameCallbac intent.setPackage("com.xixun.joey.cardsystem"); bindService(intent, cardConn, Context.BIND_AUTO_CREATE); - var connConn = new ServiceConnection() { + var connXy = new ServiceConnection() { public void onServiceDisconnected(ComponentName name) { - Util.println("Disconnected xy.conn aidl service"); - connService = null; + Util.println("<-<- AIDL Service xy.conn Disconnected"); + serviXy = null; } public void onServiceConnected(ComponentName name, IBinder iBinder) { unbindService(this); - Util.println("Bind xy.conn aidl service success"); - connService = ConnService.Stub.asInterface(iBinder); + Util.println("->-> AIDL Service xy.conn Connected"); + serviXy = ConnService.Stub.asInterface(iBinder); try { - Util.serverURL = connService.getServerURL(); + Util.serverURL = serviXy.getServerURL(); Util.println(" ServerURL: "+Util.serverURL); if(Util.serverURL==null || Util.serverURL.isEmpty()) Util.serverURL = "https://m2mled.net/"; else { @@ -205,9 +205,9 @@ public class MainActivity extends Activity implements Choreographer.FrameCallbac } } }; - intent = new Intent("xixun.intent.action.CONNECTION_INFO"); - intent.setPackage("com.xixun.xy.conn"); - bindService(intent, connConn, Context.BIND_AUTO_CREATE); + var intenXy = new Intent("xixun.intent.action.CONNECTION_INFO"); + intenXy.setPackage("com.xixun.xy.conn"); + bindService(intenXy, connXy, Context.BIND_AUTO_CREATE); reces.clear(); BroadcastReceiver rece; @@ -238,19 +238,22 @@ public class MainActivity extends Activity implements Choreographer.FrameCallbac @Override public void onReceive(Context context, Intent intent) { Util.println("Receive CHANGE_COMPANYID"); - if(connService!=null) { - try { - Util.serverURL = connService.getServerURL(); + try { + if(serviXy!=null && serviXy.asBinder().isBinderAlive()) { + Util.serverURL = serviXy.getServerURL(); Util.println(" ServerURL: "+Util.serverURL); if(Util.serverURL==null || Util.serverURL.isEmpty()) Util.serverURL = "https://m2mled.net/"; else { if(! Util.serverURL.startsWith("http")) Util.serverURL = "http://"+Util.serverURL; if(! Util.serverURL.endsWith("/")) Util.serverURL += "/"; } - } catch (Exception e) { - Util.makeText(MainActivity.this, Util.toStr(e)).show(); - Util.printStackTrace(e); + } else { + Util.println(" bindService"); + bindService(intenXy, connXy, Context.BIND_AUTO_CREATE); } + } catch (Exception e) { + Util.makeText(MainActivity.this, Util.toStr(e)).show(); + Util.printStackTrace(e); } } }, new IntentFilter("com.xixun.joey.CHANGE_COMPANYID")); diff --git a/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/Prog.java b/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/Prog.java index 9c2c1d3..6bb6814 100644 --- a/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/Prog.java +++ b/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/Prog.java @@ -179,6 +179,15 @@ public class Prog extends AbsLayout { } if(src.exitDur!=0) src.exitStart = dur*60/1000 - src.exitDur; + src.alpha = (float) source.dbl("opacity", 1); + var breathe = source.dbl("breathe"); + if(breathe > 0) src.breathe = (int) Math.round(60 / breathe); + var blink = source.dbl("blink"); + if(blink > 0) src.blinkHalf = (int) Math.round(30 / blink); + src.rotate = (float) source.dbl("rotate"); + src.scaleX = (float) source.dbl("scaleX", 1); + src.scaleY = (float) source.dbl("scaleY", 1); + var id = source.str("id"); var fileExt = source.stnn("fileExt"); if(id!=null && fileExt.startsWith(".") && new File(Util.programDir + "/" + id + fileExt).exists()) id += fileExt; @@ -266,6 +275,12 @@ public class Prog extends AbsLayout { src.exitStart = ele0.exitStart; src.isEntryRand = ele0.isEntryRand; src.isExitRand = ele0.isExitRand; + src.alpha = ele0.alpha; + src.breathe = ele0.breathe; + src.blinkHalf = ele0.blinkHalf; + src.rotate = ele0.rotate; + src.scaleX = ele0.scaleX; + src.scaleY = ele0.scaleY; } src.endTime = src.startTime + picDur; if(hasTTS) { @@ -352,14 +367,6 @@ public class Prog extends AbsLayout { if(src.view==null) continue; src.view.setVisibility(GONE); src.view.setLayoutParams(geo); - src.alpha = (float) source.dbl("opacity", 1); - var breathe = source.dbl("breathe"); - if(breathe > 0) src.breathe = (int) Math.round(60 / breathe); - var blink = source.dbl("blink"); - if(blink > 0) src.blinkHalf = (int) Math.round(30 / blink); - src.rotate = (float) source.dbl("rotate"); - src.scaleX = (float) source.dbl("scaleX", 1); - src.scaleY = (float) source.dbl("scaleY", 1); box.addView(src.view); layer.srcs.add(src); src = new Source(); diff --git a/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/SrcSensor.java b/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/SrcSensor.java index 17b1fe6..15b0127 100644 --- a/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/SrcSensor.java +++ b/XixunPlayer/app/src/main/java/com/xixun/xixunplayer/SrcSensor.java @@ -19,7 +19,7 @@ public class SrcSensor extends WebView implements IntentReceiver, Choreographer. static String directs[] = {"NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW", "N"}; MainActivity act; ArrayList htmls; - String prefix, suffix, url, text; + String prefix, url, text; int interval, pageDur, cur; @SuppressLint("SetJavaScriptEnabled") @@ -34,7 +34,6 @@ public class SrcSensor extends WebView implements IntentReceiver, Choreographer. var html = json.stnn("html").replace("%Co2", "%CO2").trim(); htmls = Txts.split(html, "

", 1); - for(int i=0; i"); pageDur = json.intg("speed")*1000; if(pageDur==0) pageDur = json.intg("timeSpan")*1000 / htmls.size(); url = json.str("sUrl"); @@ -49,14 +48,11 @@ public class SrcSensor extends WebView implements IntentReceiver, Choreographer. Util.printStackTrace(e); } } - prefix = "
"; - suffix = "
"; - if(json.bool("center")) suffix += ""; + if(json.bool("center")) prefix += "display:flex; align-items:center;"; + prefix += "\">"; prog.calls.add(this); } @@ -116,7 +112,7 @@ public class SrcSensor extends WebView implements IntentReceiver, Choreographer. .replace("%radiation", (radiation == -1 ? "--" : String.valueOf(radiation))+"W/m²") .replace("%bm", (beam == -1 ? "--" : String.valueOf(beam))+"lux"); - loadDataWithBaseURL(null, prefix+htm+suffix, "text/html", "UTF-8", null); + loadDataWithBaseURL(null, prefix+htm+"

", "text/html", "UTF-8", null); } catch (Exception e) { Util.printStackTrace(e); }