player
This commit is contained in:
parent
9741d689d0
commit
ef42b0eb98
|
@ -11,7 +11,7 @@ android {
|
|||
minSdk 21
|
||||
targetSdk 34
|
||||
versionCode 1
|
||||
versionName "2.1.4"
|
||||
versionName "2.1.9"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
|
|
|
@ -1,106 +0,0 @@
|
|||
package com.xixun.xixunplayer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.media.MediaPlayer;
|
||||
import android.view.Choreographer;
|
||||
import android.widget.VideoView;
|
||||
|
||||
public class EleVideo2 extends VideoView implements Choreographer.FrameCallback {
|
||||
|
||||
float vol = 1;
|
||||
|
||||
public EleVideo2(String path, Context context) {
|
||||
super(context);
|
||||
setVideoPath(path);
|
||||
setOnPreparedListener((MediaPlayer player)->{
|
||||
player.setLooping(true);
|
||||
if(! isShown()) {
|
||||
player.seekTo(0);
|
||||
player.pause();
|
||||
}
|
||||
if(vol!=1) player.setVolume(vol, vol);
|
||||
setOnPreparedListener(null);
|
||||
});
|
||||
setOnErrorListener((MediaPlayer mp, int what, int extra)->{
|
||||
var err = "Media Error: "+getErrorName(what)+". "+getErrorName(extra);
|
||||
Util.makeText(getContext(), err).show();
|
||||
Util.println(err);
|
||||
return true;
|
||||
});
|
||||
start();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.getSize(heightMeasureSpec));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVisibilityAggregated(boolean isVisible) {
|
||||
super.onVisibilityAggregated(isVisible);
|
||||
if(isVisible) {
|
||||
Util.println("Video Show");
|
||||
if(! isPlaying()) {
|
||||
seekTo(0);
|
||||
start();
|
||||
seekTo(0);
|
||||
if(! isPlaying()) Util.println("Video isn't Playing on Show");
|
||||
}
|
||||
} else {
|
||||
Util.println("Video Hide");
|
||||
seekTo(0);
|
||||
pause();
|
||||
seekTo(0);
|
||||
showCnt = 3;
|
||||
if(canAdd) {
|
||||
choreographer.postFrameCallback(this);
|
||||
canAdd = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Choreographer choreographer = Choreographer.getInstance();
|
||||
int showCnt;
|
||||
boolean canAdd = true;
|
||||
@Override
|
||||
public void doFrame(long frameTimeNanos) {
|
||||
if(isShown()) {
|
||||
seekTo(0);
|
||||
if(! isPlaying()) {
|
||||
start();
|
||||
seekTo(0);
|
||||
if(! isPlaying()) {
|
||||
Util.println("Video isn't Playing on doFrame "+showCnt);
|
||||
if(showCnt==0) {
|
||||
suspend();
|
||||
resume();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(showCnt>0) showCnt--;
|
||||
else {
|
||||
canAdd = true;
|
||||
return;
|
||||
}
|
||||
} else if(isPlaying()) {
|
||||
seekTo(0);
|
||||
pause();
|
||||
seekTo(0);
|
||||
Util.println("pause in doFrame()");
|
||||
}
|
||||
choreographer.postFrameCallback(this);
|
||||
canAdd = false;
|
||||
}
|
||||
|
||||
static String getErrorName(int code) {
|
||||
if(code==MediaPlayer.MEDIA_ERROR_UNKNOWN) return "UNKNOWN";
|
||||
if(code==MediaPlayer.MEDIA_ERROR_SERVER_DIED) return "SERVER_DIED";
|
||||
if(code==MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK) return "NOT_VALID_FOR_PROGRESSIVE_PLAYBACK";
|
||||
if(code==MediaPlayer.MEDIA_ERROR_IO) return "IO";
|
||||
if(code==MediaPlayer.MEDIA_ERROR_MALFORMED) return "MALFORMED";
|
||||
if(code==MediaPlayer.MEDIA_ERROR_UNSUPPORTED) return "UNSUPPORTED";
|
||||
if(code==MediaPlayer.MEDIA_ERROR_TIMED_OUT) return "TIMED_OUT";
|
||||
if(code==-2147483648) return "SYSTEM";
|
||||
return "Unknown ("+code+")";
|
||||
}
|
||||
}
|
|
@ -21,8 +21,9 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.SimpleTimeZone;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import gnph.util.Dates;
|
||||
import gnph.util.JSList;
|
||||
import gnph.util.JSMap;
|
||||
import pl.droidsonroids.gif.GifImageView;
|
||||
|
@ -98,7 +99,7 @@ public class Prog extends AbsLayout {
|
|||
JSList<JSMap> sources = layers.get(ll).jslist("sources");
|
||||
var border = layers.get(ll).jsmap("border");
|
||||
SrcBorder bdEle = null;
|
||||
int bdWidth = 0, bdStart = 0xffff, bdEnd = 0;
|
||||
int bdWidth = 0, bdStart = Integer.MAX_VALUE, bdEnd = 0;
|
||||
if(border!=null) {
|
||||
bdEle = new SrcBorder(this, Util.programDir+"/"+border.stnn("img"), border.stnn("eff"), border.intg("speed"));
|
||||
bdWidth = bdEle.img.getHeight();
|
||||
|
@ -282,11 +283,11 @@ public class Prog extends AbsLayout {
|
|||
else if(src.type.equals("AnalogClock")) src.view = new SrcAnaClock(this, geo.width, geo.height, Util.programDir + "/" + id, source);
|
||||
else if(src.type.equals("WebURL")) {
|
||||
var webView = new WebView(context);
|
||||
webView.setBackgroundColor(Color.TRANSPARENT);
|
||||
webView.getSettings().setJavaScriptEnabled(true);
|
||||
webView.setVerticalScrollBarEnabled(false);
|
||||
webView.setHorizontalScrollBarEnabled(false);
|
||||
webView.setBackgroundColor(Color.TRANSPARENT);
|
||||
webView.setInitialScale(source.intg("zoom", 100));
|
||||
webView.getSettings().setJavaScriptEnabled(true);
|
||||
webView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
|
@ -308,11 +309,11 @@ public class Prog extends AbsLayout {
|
|||
else if(src.type.startsWith("MultiLineText")) src.view = new SrcSensor(this, source, geo.width, geo.height);
|
||||
else if(src.type.startsWith("SingleLineText")) {
|
||||
var webView = new WebView(context);
|
||||
webView.setBackgroundColor(Color.TRANSPARENT);
|
||||
webView.getSettings().setJavaScriptEnabled(true);
|
||||
webView.setVerticalScrollBarEnabled(false);
|
||||
webView.setHorizontalScrollBarEnabled(false);
|
||||
webView.setBackgroundColor(Color.TRANSPARENT);
|
||||
webView.setInitialScale(100);
|
||||
webView.getSettings().setJavaScriptEnabled(true);
|
||||
webView.setLayoutParams(new AbsLayout.LayoutParams(0, -geo.height, geo.width, geo.height));
|
||||
var html = source.stnn("html");
|
||||
var prefix = "<body style=\"color:#fff; margin:0; padding:0; white-space:nowrap; ";
|
||||
|
@ -360,16 +361,23 @@ 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();
|
||||
}
|
||||
if(bdEle!=null && ! sources.isEmpty()) {
|
||||
if(bdEle!=null && bdStart < bdEnd) {
|
||||
JSList<Long> geometry = border.jslist("geometry");
|
||||
src.startTime = bdStart;
|
||||
src.endTime = bdEnd;
|
||||
src.rotate = (float) border.dbl("rotate");
|
||||
src.view = bdEle;
|
||||
src.view.setVisibility(GONE);
|
||||
box.addView(src.view, new AbsLayout.LayoutParams(geometry.get(0).intValue(), geometry.get(1).intValue(), geometry.get(2).intValue(), geometry.get(3).intValue()));
|
||||
|
@ -428,9 +436,9 @@ public class Prog extends AbsLayout {
|
|||
|
||||
public static class Source {
|
||||
View view;
|
||||
float scaleX = 1, scaleY = 1;
|
||||
float alpha = 1, rotate, scaleX = 1, scaleY = 1;
|
||||
long startMilli, endMilli = Long.MAX_VALUE;
|
||||
int startTime, entryDur, exitStart = Integer.MAX_VALUE, exitDur, endTime, ff;
|
||||
int startTime, entryDur, exitStart = Integer.MAX_VALUE, exitDur, endTime, ff, breathe, blinkHalf;
|
||||
Effect entryEff, exitEff;
|
||||
String type;
|
||||
Uri uri;
|
||||
|
@ -458,70 +466,71 @@ public class Prog extends AbsLayout {
|
|||
var w = view.getLayoutParams().width;
|
||||
var h = view.getLayoutParams().height;
|
||||
if(ff < entryDur) {
|
||||
if(entryEff == Effect.EXPAND_HOR) view.setScaleX(ff / (float) entryDur);
|
||||
else if(entryEff == Effect.EXPAND_VER) view.setScaleY(ff / (float) entryDur);
|
||||
if(entryEff == Effect.EXPAND_HOR) setScaleX(ff / (float) entryDur);
|
||||
else if(entryEff == Effect.EXPAND_VER) setScaleY(ff / (float) entryDur);
|
||||
else if(entryEff == Effect.EXPAND_LEFT) {
|
||||
view.setScaleX(ff / (float) entryDur);
|
||||
setScaleX(ff / (float) entryDur);
|
||||
view.setTranslationX((1 - view.getScaleX()) * w / 2);
|
||||
} else if(entryEff == Effect.EXPAND_TOP) {
|
||||
view.setScaleY(ff / (float) entryDur);
|
||||
setScaleY(ff / (float) entryDur);
|
||||
view.setTranslationY((1 - view.getScaleY()) * h / 2);
|
||||
} else if(entryEff == Effect.EXPAND_RIGHT) {
|
||||
view.setScaleX(ff / (float) entryDur);
|
||||
setScaleX(ff / (float) entryDur);
|
||||
view.setTranslationX((view.getScaleX() - 1) * w / 2);
|
||||
} else if(entryEff == Effect.EXPAND_BOTTOM) {
|
||||
view.setScaleY(ff / (float) entryDur);
|
||||
setScaleY(ff / (float) entryDur);
|
||||
view.setTranslationY((view.getScaleY() - 1) * h / 2);
|
||||
}
|
||||
else if(entryEff == Effect.MOVE_LEFT) view.setTranslationX(w - ff*w/(float) entryDur);
|
||||
else if(entryEff == Effect.MOVE_TOP) view.setTranslationY(h - ff*h/(float) entryDur);
|
||||
else if(entryEff == Effect.MOVE_RIGHT) view.setTranslationX(ff*w/(float) entryDur - w);
|
||||
else if(entryEff == Effect.MOVE_BOTTOM) view.setTranslationY(ff*h/(float) entryDur - h);
|
||||
else if(entryEff == Effect.FADE) view.setAlpha(ff / (float) entryDur);
|
||||
else if(entryEff == Effect.FADE) view.setAlpha(alpha * ff / entryDur);
|
||||
else if(entryEff == Effect.ZOOM) {
|
||||
view.setScaleX(ff / (float) entryDur);
|
||||
view.setScaleY(view.getScaleX());
|
||||
setScaleX(ff / (float) entryDur);
|
||||
setScaleY(view.getScaleX());
|
||||
} else if(entryEff == Effect.ZOOM_TL) {
|
||||
var rate = ff / (float) entryDur;
|
||||
view.setTranslationX((rate - 1) * w / 2);
|
||||
view.setTranslationY((rate - 1) * h / 2);
|
||||
view.setScaleX(rate);
|
||||
view.setScaleY(rate);
|
||||
setScaleX(rate);
|
||||
setScaleY(rate);
|
||||
} else if(entryEff == Effect.ZOOM_BR) {
|
||||
var rate = ff / (float) entryDur;
|
||||
view.setTranslationX((1 - rate) * w / 2);
|
||||
view.setTranslationY((1 - rate) * h / 2);
|
||||
view.setScaleX(rate);
|
||||
view.setScaleY(rate);
|
||||
setScaleX(rate);
|
||||
setScaleY(rate);
|
||||
} else if(entryEff == Effect.ZOOM_TR) {
|
||||
var rate = ff / (float) entryDur;
|
||||
view.setTranslationX((1 - rate) * w / 2);
|
||||
view.setTranslationY((rate - 1) * h / 2);
|
||||
view.setScaleX(rate);
|
||||
view.setScaleY(rate);
|
||||
setScaleX(rate);
|
||||
setScaleY(rate);
|
||||
} else if(entryEff == Effect.ZOOM_BL) {
|
||||
var rate = ff / (float) entryDur;
|
||||
view.setTranslationX((rate - 1) * w / 2);
|
||||
view.setTranslationY((1 - rate) * h / 2);
|
||||
view.setScaleX(rate);
|
||||
view.setScaleY(rate);
|
||||
setScaleX(rate);
|
||||
setScaleY(rate);
|
||||
} else if(entryEff == Effect.ROTATE) {
|
||||
view.setScaleX(ff / (float) entryDur);
|
||||
view.setScaleY(view.getScaleX());
|
||||
view.setRotation(view.getScaleX() * 360);
|
||||
setScaleX(ff / (float) entryDur);
|
||||
setScaleY(view.getScaleX());
|
||||
view.setRotation(rotate + view.getScaleX() * 360);
|
||||
} else if(entryEff == Effect.ROTATE_R) {
|
||||
view.setScaleX(ff / (float) entryDur);
|
||||
view.setScaleY(view.getScaleX());
|
||||
view.setRotation(- view.getScaleX() * 360);
|
||||
setScaleX(ff / (float) entryDur);
|
||||
setScaleY(view.getScaleX());
|
||||
view.setRotation(rotate - view.getScaleX() * 360);
|
||||
}
|
||||
} else if(ff>=exitStart) {
|
||||
if(ff-1 <= exitStart && (blinkHalf!=0 || breathe!=0)) view.setAlpha(alpha);
|
||||
var fff = ff - exitStart;
|
||||
if(fff > exitDur) fff = exitDur;
|
||||
if(exitEff == Effect.EXPAND_HOR) view.setScaleX(1 - fff / (float) exitDur);
|
||||
else if(exitEff == Effect.EXPAND_VER) view.setScaleY(1 - fff / (float) exitDur);
|
||||
if(exitEff == Effect.EXPAND_HOR) setScaleX(1 - fff / (float) exitDur);
|
||||
else if(exitEff == Effect.EXPAND_VER) setScaleY(1 - fff / (float) exitDur);
|
||||
else if(exitEff == Effect.EXPAND_LEFT) {
|
||||
var rate = fff / (float) exitDur;
|
||||
view.setScaleX(1 - rate);
|
||||
setScaleX(1 - rate);
|
||||
view.setTranslationX(rate * w / 2);
|
||||
} else if(exitEff == Effect.EXPAND_TOP) {
|
||||
var rate = fff / (float) exitDur;
|
||||
|
@ -529,66 +538,76 @@ public class Prog extends AbsLayout {
|
|||
view.setTranslationY(rate * h / 2);
|
||||
} else if(exitEff == Effect.EXPAND_RIGHT) {
|
||||
var rate = fff / (float) exitDur;
|
||||
view.setScaleX(1 - rate);
|
||||
setScaleX(1 - rate);
|
||||
view.setTranslationX(- rate * w / 2);
|
||||
} else if(exitEff == Effect.EXPAND_BOTTOM) {
|
||||
var rate = fff / (float) exitDur;
|
||||
view.setScaleY(1 - rate);
|
||||
setScaleY(1 - rate);
|
||||
view.setTranslationY(- rate * h / 2);
|
||||
}
|
||||
else if(exitEff == Effect.MOVE_LEFT) view.setTranslationX(- fff*w / (float) exitDur);
|
||||
else if(exitEff == Effect.MOVE_RIGHT) view.setTranslationX(fff*w / (float) exitDur);
|
||||
else if(exitEff == Effect.MOVE_TOP) view.setTranslationY(- fff*h / (float) exitDur);
|
||||
else if(exitEff == Effect.MOVE_BOTTOM) view.setTranslationY(fff*h / (float) exitDur);
|
||||
else if(exitEff == Effect.FADE) view.setAlpha(1 - fff / (float) exitDur);
|
||||
else if(exitEff == Effect.FADE) view.setAlpha(alpha - alpha * fff / exitDur);
|
||||
else if(exitEff == Effect.ZOOM) {
|
||||
view.setScaleX(1 - fff / (float) exitDur);
|
||||
view.setScaleY(view.getScaleX());
|
||||
setScaleX(1 - fff / (float) exitDur);
|
||||
setScaleY(view.getScaleX());
|
||||
} else if(exitEff == Effect.ZOOM_TL) {
|
||||
var rate = fff / (float) exitDur;
|
||||
view.setTranslationX(- rate * w / 2);
|
||||
view.setTranslationY(- rate * h / 2);
|
||||
view.setScaleX(1 - rate);
|
||||
view.setScaleY(1 - rate);
|
||||
setScaleX(1 - rate);
|
||||
setScaleY(1 - rate);
|
||||
} else if(exitEff == Effect.ZOOM_BR) {
|
||||
var rate = fff / (float) exitDur;
|
||||
view.setTranslationX(rate * w / 2);
|
||||
view.setTranslationY(rate * h / 2);
|
||||
view.setScaleX(1 - rate);
|
||||
view.setScaleY(1 - rate);
|
||||
setScaleX(1 - rate);
|
||||
setScaleY(1 - rate);
|
||||
} else if(exitEff == Effect.ZOOM_TR) {
|
||||
var rate = fff / (float) exitDur;
|
||||
view.setTranslationX(rate * w / 2);
|
||||
view.setTranslationY(- rate * h / 2);
|
||||
view.setScaleX(1 - rate);
|
||||
view.setScaleY(1 - rate);
|
||||
setScaleX(1 - rate);
|
||||
setScaleY(1 - rate);
|
||||
} else if(exitEff == Effect.ZOOM_BL) {
|
||||
var rate = fff / (float) exitDur;
|
||||
view.setTranslationX(- rate * w / 2);
|
||||
view.setTranslationY(rate * h / 2);
|
||||
view.setScaleX(1 - rate);
|
||||
view.setScaleY(1 - rate);
|
||||
setScaleX(1 - rate);
|
||||
setScaleY(1 - rate);
|
||||
} else if(exitEff == Effect.ROTATE) {
|
||||
var rate = fff / (float) exitDur;
|
||||
view.setScaleX(1 - rate);
|
||||
view.setScaleY(view.getScaleX());
|
||||
view.setRotation(rate * 360);
|
||||
setScaleX(1 - rate);
|
||||
setScaleY(view.getScaleX());
|
||||
view.setRotation(rotate + rate * 360);
|
||||
} else if(exitEff == Effect.ROTATE_R) {
|
||||
var rate = fff / (float) exitDur;
|
||||
view.setScaleX(1 - rate);
|
||||
view.setScaleY(view.getScaleX());
|
||||
view.setRotation(- rate * 360);
|
||||
setScaleX(1 - rate);
|
||||
setScaleY(view.getScaleX());
|
||||
view.setRotation(rotate - rate * 360);
|
||||
}
|
||||
} else resetEff();
|
||||
} else {
|
||||
resetEff();
|
||||
if(blinkHalf!=0) view.setAlpha((ff / blinkHalf & 1) == 0 ? alpha : 0);
|
||||
else if(breathe!=0) view.setAlpha((float) (Math.cos(ff%breathe*2*Math.PI/breathe)/2+0.5));
|
||||
}
|
||||
ff++;
|
||||
}
|
||||
void resetEff() {
|
||||
view.setTranslationX(0);
|
||||
view.setTranslationY(0);
|
||||
view.setAlpha(1);
|
||||
view.setAlpha(alpha);
|
||||
view.setScaleX(scaleX);
|
||||
view.setScaleY(scaleY);
|
||||
view.setRotation(0);
|
||||
view.setRotation(rotate);
|
||||
}
|
||||
void setScaleX(float val) {
|
||||
view.setScaleX(scaleX*val);
|
||||
}
|
||||
void setScaleY(float val) {
|
||||
view.setScaleY(scaleY*val);
|
||||
}
|
||||
}
|
||||
public static class Layer {
|
||||
|
@ -653,12 +672,11 @@ public class Prog extends AbsLayout {
|
|||
}
|
||||
boolean isScheOn(long milli) {
|
||||
if(sches==null) return false;
|
||||
var local = milli + Dates.zoneOff;
|
||||
var time = local % 86400000L;
|
||||
var local = milli + TimeZone.getDefault().getOffset(milli);
|
||||
int week = -1;
|
||||
for(var sche : sches) {
|
||||
if(notInRange(sche.startDate, local, sche.endDate)) continue;
|
||||
if(notInRange(sche.startTime, time, sche.endTime)) continue;
|
||||
if(notInRange(sche.startTime, local % 86400000L, sche.endTime)) continue;
|
||||
if(sche.weeks==null) return true;
|
||||
if(week==-1) week = ((int)(local / 86400000L) + 4) % 7;
|
||||
if(sche.weeks.contains(week)) return true;
|
||||
|
@ -671,23 +689,30 @@ public class Prog extends AbsLayout {
|
|||
}
|
||||
SimpleDateFormat dateFmt = new SimpleDateFormat("yyyy-MM-dd");
|
||||
SimpleDateFormat timeFmt = new SimpleDateFormat("HH:mm:ss");
|
||||
{
|
||||
var zone = new SimpleTimeZone(0, "0");
|
||||
dateFmt.getCalendar().setTimeZone(zone);
|
||||
timeFmt.getCalendar().setTimeZone(zone);
|
||||
}
|
||||
public void parse(JSList<JSMap> schedules) {
|
||||
if(schedules!=null) for(var schedule : schedules) {
|
||||
var sche = new Sche();
|
||||
var startTime = schedule.str("startTime");
|
||||
if(startTime!=null) {
|
||||
if(startTime.length()==5) startTime += ":00";
|
||||
if(startTime.length()<=5) startTime += ":00";
|
||||
try {
|
||||
sche.startTime = (int)timeFmt.parse(startTime).getTime()+Dates.zoneOff;
|
||||
sche.startTime = (int)timeFmt.parse(startTime).getTime();
|
||||
Util.println("startTime "+timeFmt.format(sche.startTime));
|
||||
} catch (ParseException e) {
|
||||
Util.printStackTrace(e);
|
||||
}
|
||||
}
|
||||
var endTime = schedule.str("endTime");
|
||||
if(endTime!=null) {
|
||||
if(endTime.length()==5) endTime += ":00";
|
||||
if(endTime.length()<=5) endTime += ":00";
|
||||
try {
|
||||
sche.endTime = (int)timeFmt.parse(endTime).getTime()+Dates.zoneOff;
|
||||
sche.endTime = (int)timeFmt.parse(endTime).getTime();
|
||||
Util.println("endTime "+timeFmt.format(sche.endTime));
|
||||
} catch (ParseException e) {
|
||||
Util.printStackTrace(e);
|
||||
}
|
||||
|
@ -696,7 +721,7 @@ public class Prog extends AbsLayout {
|
|||
var startDate = schedule.str("startDate");
|
||||
if(startDate!=null) {
|
||||
try {
|
||||
sche.startDate = dateFmt.parse(startDate).getTime() + Dates.zoneOff;
|
||||
sche.startDate = dateFmt.parse(startDate).getTime();
|
||||
} catch (ParseException e) {
|
||||
Util.printStackTrace(e);
|
||||
}
|
||||
|
@ -704,7 +729,7 @@ public class Prog extends AbsLayout {
|
|||
var endDate = schedule.str("endDate");
|
||||
if(endDate!=null) {
|
||||
try {
|
||||
sche.endDate = dateFmt.parse(endDate).getTime() + Dates.zoneOff + 86400000L;
|
||||
sche.endDate = dateFmt.parse(endDate).getTime() + 86400000L;
|
||||
} catch (ParseException e) {
|
||||
Util.printStackTrace(e);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import java.io.ByteArrayOutputStream;
|
|||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
|
@ -27,6 +26,7 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
|
@ -93,7 +93,7 @@ public class SocketThread extends Thread {
|
|||
new File(Util.programDir + "/" + name).delete();
|
||||
}
|
||||
}
|
||||
} else if("imgFileStart".equals(_type)) {
|
||||
} else if("SetBackImg".equals(_type) || "imgFileStart".equals(_type)) {
|
||||
var size = obj.intg("size");
|
||||
var fout = new FileOutputStream(Util.backImgFile);
|
||||
IOs.write(fout, in, size);
|
||||
|
@ -104,7 +104,6 @@ public class SocketThread extends Thread {
|
|||
main.backView.cosImg = BitmapFactory.decodeFile(Util.backImgFile, Util.noScaled);
|
||||
main.backView.invalidate();
|
||||
});
|
||||
} else if("imgFileEnd".equals(_type)) {
|
||||
new JSMap("success", true).write(out);
|
||||
} else if("proEnd".equals(_type)) {
|
||||
new JSMap("success", progJson!=null).write(out);
|
||||
|
@ -178,18 +177,18 @@ public class SocketThread extends Thread {
|
|||
).write(out);
|
||||
} else if("GetInfo".equals(_type)) {
|
||||
var writer = new OutputStreamWriter(out);
|
||||
var Fmt = new SimpleDateFormat("yy-MM-dd HH:mm:ss.SSS");
|
||||
var fmt = new SimpleDateFormat("yy-MM-dd HH:mm:ss.SSS");
|
||||
var dur = 0;
|
||||
if(main.progView!=null) for(var page : main.progView.pages) dur += page.tDur;
|
||||
writer.append("ProgSend: ").append(Fmt.format(new File(Util.programDir + "/program").lastModified())).append(" ProgDur: ").append(String.valueOf(dur)).append("ms");
|
||||
writer.append("ProgSend: ").append(fmt.format(new File(Util.programDir + "/program").lastModified())).append(" ProgDur: ").append(String.valueOf(dur)).append("ms");
|
||||
if(main.progView!=null) writer.append(" Size Avas: ").append(String.valueOf(main.progView.avas.size())).append(" Pages: ").append(String.valueOf(main.progView.pages.size()));
|
||||
writer.append("\n");
|
||||
writer.append(" Launch: ").append(Fmt.format(main.launchMilli)).append("\n");
|
||||
writer.append(" Sync: ").append(Fmt.format(main.syncMs)).append("\n");
|
||||
writer.append(" Launch: ").append(fmt.format(main.launchMilli)).append("\n");
|
||||
writer.append(" Sync: ").append(fmt.format(main.syncMs)).append("\n");
|
||||
if(main.progView==null) writer.append(" ProgView is Null\n");
|
||||
else if(main.progView.avas.isEmpty()) writer.append(" No Avas\n");
|
||||
else writer.append("Page End: ").append(Fmt.format(main.progView.curAva().endMilli)).append(" CurPage: ").append(String.valueOf(main.progView.curAva)).append(" / ").append(String.valueOf(main.progView.avas.get(main.progView.curAva))).append("\n");
|
||||
writer.append(" Current: ").append(Fmt.format(System.currentTimeMillis())).append("\n");
|
||||
else writer.append("Page End: ").append(fmt.format(main.progView.curAva().endMilli)).append(" CurPage: ").append(String.valueOf(main.progView.curAva)).append(" / ").append(String.valueOf(main.progView.avas.get(main.progView.curAva))).append("\n");
|
||||
writer.append(" Current: ").append(fmt.format(System.currentTimeMillis())).append(" ").append(String.valueOf(TimeZone.getDefault().getRawOffset()/3600000f)).append(" ").append(TimeZone.getDefault().getDisplayName()).append("\n");
|
||||
var statFs = new StatFs(Environment.getExternalStorageDirectory().getPath());
|
||||
writer.append(" Disk: ").append(String.valueOf(statFs.getTotalBytes()/1000000)).append(" ").append(String.valueOf(statFs.getAvailableBytes()/1000000)).append(" ").append(String.valueOf(statFs.getFreeBytes()/1000000)).append(" (total avail free)\n");
|
||||
var actManager = (ActivityManager) main.getSystemService(main.ACTIVITY_SERVICE);
|
||||
|
@ -262,7 +261,6 @@ public class SocketThread extends Thread {
|
|||
Arrays.sort(files, (f1, f2) -> (int) (f2.lastModified() - f1.lastModified()));
|
||||
var writer = new OutputStreamWriter(out);
|
||||
for(var file : files) writer.append(fmt.format(new Date(file.lastModified()))).append(' ').append(file.getName()).append(' ').append(String.valueOf(file.length())).append('\n');
|
||||
writer.append('\n');
|
||||
writer.flush();
|
||||
}
|
||||
} else if("GetFile".equals(_type)) {
|
||||
|
@ -276,6 +274,17 @@ public class SocketThread extends Thread {
|
|||
IOs.writeCloseIn(out, new FileInputStream(file));
|
||||
}
|
||||
}
|
||||
} else if("GetJsonWithFileInfo".equals(_type)) {
|
||||
var prog = new File(Util.programDir+"/program");
|
||||
if(! prog.isFile()) new JSMap("msg", "'program' file not exist").write(out);
|
||||
else {
|
||||
var json = IOs.readStrClose(new FileInputStream(prog));
|
||||
var files = new File(Util.programDir).listFiles();
|
||||
if(files!=null) for(var file : files) if(! "program".equals(file.getName())) json = json.replace("\""+file.getName()+"\"", "\""+file.getName()+"\"/*"+file.length()+" "+fmt.format(new Date(file.lastModified()))+"*/");
|
||||
var writer = new OutputStreamWriter(out);
|
||||
writer.append(json);
|
||||
writer.flush();
|
||||
}
|
||||
}
|
||||
out.flush();
|
||||
Util.println("cmd end");
|
||||
|
|
|
@ -8,6 +8,8 @@ import android.graphics.Path;
|
|||
import android.view.Choreographer;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
@SuppressLint("ViewConstructor")
|
||||
public class SrcBorder extends View implements Choreographer.FrameCallback {
|
||||
Bitmap img;
|
||||
|
@ -45,7 +47,7 @@ public class SrcBorder extends View implements Choreographer.FrameCallback {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
protected void onDraw(@NonNull Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
if(eff!='b' || offs[0] <= 0) {
|
||||
int bdWidth = img.getHeight();
|
||||
|
|
|
@ -239,7 +239,8 @@ public class SrcDigiClock extends LinearBox implements Choreographer.FrameCallba
|
|||
void cal() {
|
||||
//var dt = timeZone==null ? LocalDateTime.now() : LocalDateTime.now(timeZone);
|
||||
calendar.setTimeInMillis(lastSec*1000);
|
||||
var hms = timeptn.format(calendar.getTime());
|
||||
var date = calendar.getTime();
|
||||
var hms = timeptn.format(date);
|
||||
ampmComp.setImageBitmap(imgs.get(calendar.get(Calendar.HOUR_OF_DAY) < 12?"AM":"PM"));
|
||||
hourComps[0].setImageBitmap(imgs.get(hms.substring(0,1)));
|
||||
hourComps[1].setImageBitmap(imgs.get(hms.substring(1,2)));
|
||||
|
@ -247,9 +248,10 @@ public class SrcDigiClock extends LinearBox implements Choreographer.FrameCallba
|
|||
minComps[1].setImageBitmap(imgs.get(hms.substring(3,4)));
|
||||
secComps[0].setImageBitmap(imgs.get(hms.substring(4,5)));
|
||||
secComps[1].setImageBitmap(imgs.get(hms.substring(5,6)));
|
||||
if(yearComps[0].getDrawable()==null || (calendar.get(Calendar.HOUR_OF_DAY)==0 && calendar.get(Calendar.SECOND)==0)) {
|
||||
var ymd = dataFmt.format(date);
|
||||
if(yearComps[0].getDrawable()==null || ! ymd.equals(lastYmd)) {
|
||||
lastYmd = ymd;
|
||||
if(weekly) weekComp.setImageBitmap(imgs.get(weeks[calendar.get(Calendar.DAY_OF_WEEK) - 1]));
|
||||
var ymd = dataFmt.format(calendar.getTime());
|
||||
yearComps[0].setImageBitmap(imgs.get(ymd.substring(0,1)));
|
||||
yearComps[1].setImageBitmap(imgs.get(ymd.substring(1,2)));
|
||||
yearComps[2].setImageBitmap(imgs.get(ymd.substring(2,3)));
|
||||
|
@ -260,6 +262,7 @@ public class SrcDigiClock extends LinearBox implements Choreographer.FrameCallba
|
|||
dayComps[1].setImageBitmap(imgs.get(ymd.substring(7,8)));
|
||||
}
|
||||
}
|
||||
String lastYmd;
|
||||
|
||||
long lastSec;
|
||||
|
||||
|
|
|
@ -1,174 +0,0 @@
|
|||
package com.xixun.xixunplayer;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.view.Choreographer;
|
||||
import android.view.View;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import gnph.util.JSList;
|
||||
import gnph.util.JSMap;
|
||||
|
||||
public class SrcImage extends View implements Choreographer.FrameCallback {
|
||||
|
||||
static final char effTypes[] = {'l', 't', 'r', 'b'};
|
||||
Bitmap img;
|
||||
Rect RECT = new Rect();
|
||||
RectF rect;
|
||||
Paint paint = new Paint();
|
||||
int entryDur, exitStart;
|
||||
char entryType, exitType;
|
||||
boolean isEntryRand, isExitRand;
|
||||
|
||||
public SrcImage(Context context, JSMap map, int w, int h) {
|
||||
super(context);
|
||||
RECT.right = w;
|
||||
RECT.bottom = h;
|
||||
img = BitmapFactory.decodeFile(Util.programDir+"/"+map.stnn("id"));
|
||||
if(img==null) return;
|
||||
rect = new RectF(0, 0, w, h);
|
||||
// entryDur = map.intg("entryEffectTimeSpan")*60;
|
||||
// if(entryDur > 0) {
|
||||
// var effStr = map.str("entryEffect");
|
||||
// if(effStr == null || effStr.equalsIgnoreCase("None")) entryDur = 0;
|
||||
// else if(effStr.equalsIgnoreCase("moving_left")) entryType = 'l';
|
||||
// else if(effStr.equalsIgnoreCase("moving_top")) entryType = 't';
|
||||
// else if(effStr.equalsIgnoreCase("moving_right")) entryType = 'r';
|
||||
// else if(effStr.equalsIgnoreCase("moving_bottom")) entryType = 'b';
|
||||
// else if(effStr.equalsIgnoreCase("alpha_in")) entryType = 'a';
|
||||
// else if(effStr.equalsIgnoreCase("zoom_in")) entryType = 'z';
|
||||
// else if(effStr.equalsIgnoreCase("Random")) isEntryRand = true;
|
||||
// else entryDur = 0;
|
||||
// }
|
||||
// var exitDur = map.intg("exitEffectTimeSpan")*60;
|
||||
// if(exitDur > 0) {
|
||||
// var effStrExit = map.str("exitEffect");
|
||||
// if(effStrExit == null || effStrExit.equalsIgnoreCase("None")) exitDur = 0;
|
||||
// else if(effStrExit.equalsIgnoreCase("moving_left")) exitType = 'l';
|
||||
// else if(effStrExit.equalsIgnoreCase("moving_top")) exitType = 't';
|
||||
// else if(effStrExit.equalsIgnoreCase("moving_right")) exitType = 'r';
|
||||
// else if(effStrExit.equalsIgnoreCase("moving_bottom")) exitType = 'b';
|
||||
// else if(effStrExit.equalsIgnoreCase("alpha_out")) exitType = 'a';
|
||||
// else if(effStrExit.equalsIgnoreCase("zoom_out")) exitType = 'z';
|
||||
// else if(effStrExit.equalsIgnoreCase("Random")) isExitRand = true;
|
||||
// else exitDur = 0;
|
||||
// }
|
||||
// exitStart = exitDur==0 ? Integer.MAX_VALUE : map.intg("timeSpan")*60 - exitDur;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
drawOther(canvas, this);
|
||||
}
|
||||
public void drawOther(Canvas canvas, View view) {
|
||||
// var fff = ff==0 ? 0 : ff-1;
|
||||
// if(fff < entryDur) {
|
||||
// if(entryType=='l') {
|
||||
// rect.left = RECT.right - fff*RECT.right/(float) entryDur;
|
||||
// rect.right = rect.left + RECT.right;
|
||||
// canvas.drawBitmap(img, null, rect, null);
|
||||
// } else if(entryType=='r') {
|
||||
// rect.left = -RECT.right + fff*RECT.right/(float) entryDur;
|
||||
// rect.right = rect.left + RECT.right;
|
||||
// canvas.drawBitmap(img, null, rect, null);
|
||||
// } else if(entryType=='t') {
|
||||
// rect.top = RECT.bottom - fff*RECT.bottom/(float) entryDur;
|
||||
// rect.bottom = rect.top + RECT.bottom;
|
||||
// canvas.drawBitmap(img, null, rect, null);
|
||||
// } else if(entryType=='b') {
|
||||
// rect.top = -RECT.bottom + fff*RECT.bottom/(float) entryDur;
|
||||
// rect.bottom = rect.top + RECT.bottom;
|
||||
// canvas.drawBitmap(img, null, rect, null);
|
||||
// } else if(entryType=='a') {
|
||||
// paint.setAlpha(fff*255/entryDur);
|
||||
// canvas.drawBitmap(img, null, rect, paint);
|
||||
// } else if(entryType=='z') {
|
||||
// var haw = RECT.right/2f;
|
||||
// var hah = RECT.bottom/2f;
|
||||
// var ww = fff*haw/(float) entryDur;
|
||||
// var hh = fff*hah/(float) entryDur;
|
||||
// rect.left = haw - ww;
|
||||
// rect.right = haw + ww;
|
||||
// rect.top = hah - hh;
|
||||
// rect.bottom = hah + hh;
|
||||
// canvas.drawBitmap(img, null, rect, null);
|
||||
// }
|
||||
// } else if(fff>=exitStart) {
|
||||
// fff -= exitStart;
|
||||
// if(exitType=='l') {
|
||||
// rect.left = - fff*RECT.right/(float) entryDur;
|
||||
// rect.right = rect.left + RECT.right;
|
||||
// canvas.drawBitmap(img, null, rect, null);
|
||||
// } else if(exitType=='r') {
|
||||
// rect.left = fff*RECT.right/(float) entryDur;
|
||||
// rect.right = rect.left + RECT.right;
|
||||
// canvas.drawBitmap(img, null, rect, null);
|
||||
// } else if(exitType=='t') {
|
||||
// rect.top = - fff*RECT.bottom/(float) entryDur;
|
||||
// rect.bottom = rect.top + RECT.bottom;
|
||||
// canvas.drawBitmap(img, null, rect, null);
|
||||
// } else if(exitType=='b') {
|
||||
// rect.top = fff*RECT.bottom/(float) entryDur;
|
||||
// rect.bottom = rect.top + RECT.bottom;
|
||||
// canvas.drawBitmap(img, null, rect, null);
|
||||
// } else if(exitType=='a') {
|
||||
// paint.setAlpha(255 - fff*255/entryDur);
|
||||
// canvas.drawBitmap(img, null, rect, paint);
|
||||
// } else if(exitType=='z') {
|
||||
// var haw = RECT.right/2f;
|
||||
// var hah = RECT.bottom/2f;
|
||||
// var ww = haw - fff*haw/(float) entryDur;
|
||||
// var hh = hah - fff*hah/(float) entryDur;
|
||||
// rect.left = haw - ww;
|
||||
// rect.right = haw + ww;
|
||||
// rect.top = hah - hh;
|
||||
// rect.bottom = hah + hh;
|
||||
// canvas.drawBitmap(img, null, rect, null);
|
||||
// }
|
||||
// } else
|
||||
canvas.drawBitmap(img, null, RECT, null);
|
||||
}
|
||||
|
||||
Choreographer choreographer = Choreographer.getInstance();
|
||||
int ff;
|
||||
boolean canAdd = true;
|
||||
|
||||
// @Override
|
||||
// public void onVisibilityAggregated(boolean isVisible) {
|
||||
// super.onVisibilityAggregated(isVisible);
|
||||
// ff = 0;
|
||||
// if(isVisible) {
|
||||
// if(canAdd && (entryDur > 0 || exitStart < Integer.MAX_VALUE)) {
|
||||
// choreographer.postFrameCallback(this);
|
||||
// canAdd = false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@Override
|
||||
public void doFrame(long frameTimeNanos) {
|
||||
if(! isShown()) {
|
||||
canAdd = true;
|
||||
return;
|
||||
}
|
||||
if(ff <= entryDur || ff>=exitStart) {
|
||||
if(ff==0) {
|
||||
if(isEntryRand) entryType = effTypes[Util.rand.nextInt(4)];
|
||||
if(isExitRand) exitType = effTypes[Util.rand.nextInt(4)];
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
ff++;
|
||||
choreographer.postFrameCallback(this);
|
||||
canAdd = false;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user