player
This commit is contained in:
parent
03df39b539
commit
d7409bc19f
|
@ -577,8 +577,8 @@ public class MainActivity extends ComponentActivity implements Choreographer.Fra
|
||||||
var page = page(progView.curAva);
|
var page = page(progView.curAva);
|
||||||
for(var layer : page.layers) for(var src : layer.srcs) if(src.view.getVisibility()==VISIBLE) {
|
for(var layer : page.layers) for(var src : layer.srcs) if(src.view.getVisibility()==VISIBLE) {
|
||||||
try {
|
try {
|
||||||
if(src.view instanceof EleVideo) {
|
if(src.view instanceof SrcVideo) {
|
||||||
var view = (EleVideo) src.view;
|
var view = (SrcVideo) src.view;
|
||||||
if(view.ijkPlayer!=null) {
|
if(view.ijkPlayer!=null) {
|
||||||
writer.append("VideoPlaying: ").append(String.valueOf(view.ijkPlayer.isPlaying())).append("\tCur/Dur: ").append(String.valueOf(view.ijkPlayer.getCurrentPosition())).append("/").append(String.valueOf(view.ijkPlayer.getDuration())).append("\n");
|
writer.append("VideoPlaying: ").append(String.valueOf(view.ijkPlayer.isPlaying())).append("\tCur/Dur: ").append(String.valueOf(view.ijkPlayer.getCurrentPosition())).append("/").append(String.valueOf(view.ijkPlayer.getDuration())).append("\n");
|
||||||
var mediaInfo = view.ijkPlayer.getMediaInfo();
|
var mediaInfo = view.ijkPlayer.getMediaInfo();
|
||||||
|
|
|
@ -73,16 +73,16 @@ public class Prog extends AbsLayout {
|
||||||
var page = new Page();
|
var page = new Page();
|
||||||
page.repeatTimes = pageMap.intg("repeatTimes", 1);
|
page.repeatTimes = pageMap.intg("repeatTimes", 1);
|
||||||
page.parse(pageMap.jslist("schedules"));
|
page.parse(pageMap.jslist("schedules"));
|
||||||
HashMap<String, EleVideo> videoMap = new HashMap<>();
|
HashMap<String, SrcVideo> videoMap = new HashMap<>();
|
||||||
for(int ll=layers.size()-1; ll>=0; ll--) {
|
for(int ll=layers.size()-1; ll>=0; ll--) {
|
||||||
var layer = new Layer();
|
var layer = new Layer();
|
||||||
layer.isLoop = layers.get(ll).bool("repeat");
|
layer.isLoop = layers.get(ll).bool("repeat");
|
||||||
JSList<JSMap> sources = layers.get(ll).jslist("sources");
|
JSList<JSMap> sources = layers.get(ll).jslist("sources");
|
||||||
var border = layers.get(ll).jsmap("border");
|
var border = layers.get(ll).jsmap("border");
|
||||||
EleBorder bdEle = null;
|
SrcBorder bdEle = null;
|
||||||
int bdWidth = 0, bdStart = 0xffff, bdEnd = 0;
|
int bdWidth = 0, bdStart = 0xffff, bdEnd = 0;
|
||||||
if(border!=null) {
|
if(border!=null) {
|
||||||
bdEle = new EleBorder(Util.programDir+"/"+border.stnn("img"), border.stnn("eff"), border.intg("speed"), context);
|
bdEle = new SrcBorder(Util.programDir+"/"+border.stnn("img"), border.stnn("eff"), border.intg("speed"), context);
|
||||||
bdWidth = bdEle.img.getHeight();
|
bdWidth = bdEle.img.getHeight();
|
||||||
}
|
}
|
||||||
var src = new Source();
|
var src = new Source();
|
||||||
|
@ -174,7 +174,7 @@ public class Prog extends AbsLayout {
|
||||||
var speechRate = (float) source.dbl("voiceRate");
|
var speechRate = (float) source.dbl("voiceRate");
|
||||||
if(mode!=null ? mode.endsWith("roll") : (imgs.size()==1 && imgs.get(0).intg("picDuration")==0)) {
|
if(mode!=null ? mode.endsWith("roll") : (imgs.size()==1 && imgs.get(0).intg("picDuration")==0)) {
|
||||||
var img = imgs.get(0);
|
var img = imgs.get(0);
|
||||||
src.view = new EleScroll(context, img);
|
src.view = new SrcScroll(context, img);
|
||||||
if(hasTTS) {
|
if(hasTTS) {
|
||||||
src.text = img.str("text");
|
src.text = img.str("text");
|
||||||
if(src.text!=null) {
|
if(src.text!=null) {
|
||||||
|
@ -225,7 +225,7 @@ public class Prog extends AbsLayout {
|
||||||
} else if(src.type.equals("DigitalClock")) src.view = new SrcDigitalClock(context, source);
|
} else if(src.type.equals("DigitalClock")) src.view = new SrcDigitalClock(context, source);
|
||||||
else if(src.type.startsWith("DigitalClock")) src.view = new SrcDigiClock(context, source);
|
else if(src.type.startsWith("DigitalClock")) src.view = new SrcDigiClock(context, source);
|
||||||
else if(src.type.equals("AnalogClock")) src.view = new SrcAnaClock(geo.width, geo.height, Util.programDir + "/" + id, source, context);
|
else if(src.type.equals("AnalogClock")) src.view = new SrcAnaClock(geo.width, geo.height, Util.programDir + "/" + id, source, context);
|
||||||
else if(src.type.equals("Audio")) src.view = new EleVideo(context, Util.programDir + "/" +id, source.intg("vol", 100) / 100.0f, false);
|
else if(src.type.equals("Audio")) src.view = new SrcVideo(context, Util.programDir + "/" +id, source.intg("vol", 100) / 100.0f, false);
|
||||||
else if(src.type.endsWith("Video")) {
|
else if(src.type.endsWith("Video")) {
|
||||||
var isLive = src.type.startsWith("Live");
|
var isLive = src.type.startsWith("Live");
|
||||||
var url = source.str("url");
|
var url = source.str("url");
|
||||||
|
@ -241,8 +241,8 @@ public class Prog extends AbsLayout {
|
||||||
src.view = new SrcCopy(context, videoView);
|
src.view = new SrcCopy(context, videoView);
|
||||||
((SrcCopy) src.view).scaleX = 0;
|
((SrcCopy) src.view).scaleX = 0;
|
||||||
} else {
|
} else {
|
||||||
src.view = new EleVideo(context, isLive ? url : Util.programDir+"/"+id, source.intg("vol", 100) / 100.0f, isLive);
|
src.view = new SrcVideo(context, isLive ? url : Util.programDir+"/"+id, source.intg("vol", 100) / 100.0f, isLive);
|
||||||
videoMap.put(key, (EleVideo) src.view);
|
videoMap.put(key, (SrcVideo) src.view);
|
||||||
}
|
}
|
||||||
} else if(src.type.equals("WebURL")) {
|
} else if(src.type.equals("WebURL")) {
|
||||||
var webView = new WebView(context);
|
var webView = new WebView(context);
|
||||||
|
@ -307,7 +307,7 @@ public class Prog extends AbsLayout {
|
||||||
try {
|
try {
|
||||||
setVisibility(GONE);
|
setVisibility(GONE);
|
||||||
View view;
|
View view;
|
||||||
for(int cc=0; cc<getChildCount(); cc++) if((view = getChildAt(cc)) instanceof EleVideo) ((EleVideo) view).release();
|
for(int cc=0; cc<getChildCount(); cc++) if((view = getChildAt(cc)) instanceof SrcVideo) ((SrcVideo) view).release();
|
||||||
for(var page : pages) for(var layer : page.layers) for(var src : layer.srcs) if(src.tts!=null) src.tts.shutdown();
|
for(var page : pages) for(var layer : page.layers) for(var src : layer.srcs) if(src.tts!=null) src.tts.shutdown();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Util.printStackTrace(e);
|
Util.printStackTrace(e);
|
||||||
|
|
|
@ -9,7 +9,7 @@ import android.graphics.Path;
|
||||||
import android.view.Choreographer;
|
import android.view.Choreographer;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
public class EleBorder extends View implements Choreographer.FrameCallback {
|
public class SrcBorder extends View implements Choreographer.FrameCallback {
|
||||||
Bitmap img;
|
Bitmap img;
|
||||||
int[] lens = new int[4];
|
int[] lens = new int[4];
|
||||||
Path[] paths = new Path[4];
|
Path[] paths = new Path[4];
|
||||||
|
@ -17,7 +17,7 @@ public class EleBorder extends View implements Choreographer.FrameCallback {
|
||||||
byte eff;
|
byte eff;
|
||||||
int interval;
|
int interval;
|
||||||
|
|
||||||
public EleBorder(String path, String eff, int speed, Context context) {
|
public SrcBorder(String path, String eff, int speed, Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
img = BitmapFactory.decodeFile(path);
|
img = BitmapFactory.decodeFile(path);
|
||||||
if(eff.startsWith("ro")) this.eff = 'r';
|
if(eff.startsWith("ro")) this.eff = 'r';
|
|
@ -17,7 +17,7 @@ import java.util.List;
|
||||||
import gnph.util.JSMap;
|
import gnph.util.JSMap;
|
||||||
|
|
||||||
@SuppressLint("ViewConstructor")
|
@SuppressLint("ViewConstructor")
|
||||||
public class EleScroll extends View implements Choreographer.FrameCallback {
|
public class SrcScroll extends View implements Choreographer.FrameCallback {
|
||||||
|
|
||||||
ArrayList<Bitmap> imgs = new ArrayList<>();
|
ArrayList<Bitmap> imgs = new ArrayList<>();
|
||||||
Rect rect = new Rect();
|
Rect rect = new Rect();
|
||||||
|
@ -25,7 +25,7 @@ public class EleScroll extends View implements Choreographer.FrameCallback {
|
||||||
int interval, cur, end, step;
|
int interval, cur, end, step;
|
||||||
char effect;
|
char effect;
|
||||||
|
|
||||||
public EleScroll(Context context, JSMap json) {
|
public SrcScroll(Context context, JSMap json) {
|
||||||
super(context);
|
super(context);
|
||||||
var img = BitmapFactory.decodeFile(Util.programDir+"/"+json.stnn("id"));
|
var img = BitmapFactory.decodeFile(Util.programDir+"/"+json.stnn("id"));
|
||||||
imgsWidth = img.getWidth();
|
imgsWidth = img.getWidth();
|
|
@ -16,7 +16,7 @@ import androidx.media3.exoplayer.SeekParameters;
|
||||||
import tv.danmaku.ijk.media.player.IMediaPlayer;
|
import tv.danmaku.ijk.media.player.IMediaPlayer;
|
||||||
import tv.danmaku.ijk.media.player.IjkMediaPlayer;
|
import tv.danmaku.ijk.media.player.IjkMediaPlayer;
|
||||||
|
|
||||||
public class EleVideo extends TextureView implements TextureView.SurfaceTextureListener {
|
public class SrcVideo extends TextureView implements TextureView.SurfaceTextureListener {
|
||||||
|
|
||||||
String path;
|
String path;
|
||||||
float vol;
|
float vol;
|
||||||
|
@ -25,7 +25,7 @@ public class EleVideo extends TextureView implements TextureView.SurfaceTextureL
|
||||||
long bitRate;
|
long bitRate;
|
||||||
boolean isLive;
|
boolean isLive;
|
||||||
|
|
||||||
public EleVideo(Context context, String path, float vol, boolean isLive) {
|
public SrcVideo(Context context, String path, float vol, boolean isLive) {
|
||||||
super(context);
|
super(context);
|
||||||
this.path = path;
|
this.path = path;
|
||||||
this.vol = vol;
|
this.vol = vol;
|
|
@ -0,0 +1,95 @@
|
||||||
|
package com.xixun.xixunplayer;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.webkit.WebView;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import gnph.util.IOs;
|
||||||
|
import gnph.util.JSList;
|
||||||
|
import gnph.util.JSMap;
|
||||||
|
import gnph.util.NumFmts;
|
||||||
|
import gnph.util.Txts;
|
||||||
|
import gnph.util.URLConn;
|
||||||
|
|
||||||
|
@SuppressLint("ViewConstructor")
|
||||||
|
public class SrcVisitor extends WebView {
|
||||||
|
|
||||||
|
String html, lineHeight, prefix, url;
|
||||||
|
|
||||||
|
public SrcVisitor(Context context, JSMap json) {
|
||||||
|
super(context);
|
||||||
|
setBackgroundColor(Color.TRANSPARENT);
|
||||||
|
setVerticalScrollBarEnabled(false);
|
||||||
|
setHorizontalScrollBarEnabled(false);
|
||||||
|
setInitialScale(100);
|
||||||
|
html = json.stnn("html").replace("%{yesterday.", "%{arr.-1.");
|
||||||
|
lineHeight = json.str("lineHeight");
|
||||||
|
url = json.str("url");
|
||||||
|
prefix = "<body style=\"color:#fff;margin:0;padding:0;";
|
||||||
|
if(lineHeight!=null) prefix += "line-height:"+lineHeight+";";
|
||||||
|
prefix += "\">";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refresh() {
|
||||||
|
try {
|
||||||
|
var htm = html;
|
||||||
|
try {
|
||||||
|
var res = JSMap.fromClose(new URLConn(url).in()).jsmap("data");
|
||||||
|
int lastEnd = 0, appendIdx = 0;
|
||||||
|
var buf = new StringBuilder(htm.length()*3/2);
|
||||||
|
int start;
|
||||||
|
while((start = htm.indexOf("%{", lastEnd)) > -1) {
|
||||||
|
int fds = start+2, fde = start+2;
|
||||||
|
try {
|
||||||
|
for(; fde<=fds+16; fde++) if(htm.charAt(fde)=='}') break;
|
||||||
|
if(fde > fds+16) {
|
||||||
|
lastEnd = fds;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
lastEnd = fde+1;
|
||||||
|
if(fde == fds) continue;
|
||||||
|
var fd = htm.substring(fds, fde);
|
||||||
|
var replace = res.str(fd);
|
||||||
|
if(replace!=null) {
|
||||||
|
buf.append(htm, appendIdx, start).append(replace);
|
||||||
|
appendIdx = lastEnd;
|
||||||
|
}
|
||||||
|
Util.println("Found: " + htm.substring(start, lastEnd)+" fd "+fd);
|
||||||
|
} catch (Exception e) {
|
||||||
|
lastEnd = fds;
|
||||||
|
Util.printStackTrace(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(buf.length()>0) {
|
||||||
|
if(appendIdx < htm.length()) buf.append(htm, appendIdx, htm.length());
|
||||||
|
htm = buf.toString();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Util.printStackTrace(e);
|
||||||
|
}
|
||||||
|
loadDataWithBaseURL(null, prefix+htm+"</body>", "text/html", "UTF-8", null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Util.printStackTrace(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
long nextMs;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onVisibilityAggregated(boolean isVisible) {
|
||||||
|
super.onVisibilityAggregated(isVisible);
|
||||||
|
if(isVisible) {
|
||||||
|
var ms = System.currentTimeMillis();
|
||||||
|
if(ms>=nextMs) {
|
||||||
|
nextMs += 15000;
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user