package xplay;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
class Rect {
Rect(int _x, int _y, int _width, int _height) {
x = _x;
y = _y;
width = _width;
height = _height;
}
int x;
int y;
int width;
int height;
}
class Dep {
String path; // 素材路径
String type; // 素材类型(video or pic)
int duration; // 素材持续时间(非视频)
}
public class XplayCtl {
XplayCtl(String _host, int _port) {
host = _host;
port = _port;
}
private String host;
private int port;
private Socket socket = null;
private boolean connXplay(String _data) {
try {
if (socket == null || !socket.isConnected())
socket = new Socket(host, port);
OutputStreamWriter os = new OutputStreamWriter(socket.getOutputStream(), "UTF-8");
os.write(_data + "\n#End\n");
os.flush();
BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream(), "UTF-8"));
String data = null;
while ((data = br.readLine()) != null) {
if (data.contains("#End"))
break;
System.out.println(data);
}
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
}
return true;
}
private boolean playXplay(Map<String, Object> _data) {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String json = gson.toJson(_data);
JsonParser jp = new JsonParser();
JsonElement je = jp.parse(json);
String prettyJsonString = gson.toJson(je);
System.out.print(prettyJsonString);
return this.connXplay(prettyJsonString);
}
/*
* 序列(视频与图片)
* _content 一组素材,每一个素材为一个 Dep 包含素材路径、类型(libName)、持续时间(非视频)
*/
public boolean playSequence(long _start, String _id, int _index, ArrayList<Dep> _content, Rect _rect, String _mode,
int _rotate) {
Map<String, Object> data = new HashMap<String, Object>();
Map<String, Object> params = new HashMap<String, Object>();
data.put("id", _id);
data.put("type", "sequence");
data.put("start", _start);
data.put("libName", "video");
params.put("zIndex", _index);
params.put("left", _rect.x);
params.put("top", _rect.y);
params.put("width", _rect.width);
params.put("height", _rect.height);
params.put("screen_mode", _mode);
params.put("screen_rotate", _rotate);
data.put("params", params);
data.put("deps", _content);
return this.playXplay(data);
}
/*
* 视频或流媒体等 ...
* _start 该素材开始播放的时间精确到毫秒 (视频预加载问题:
* 提前500ms-1000ms发送指令xplay可以预加载视频)(也就是_start时间是12:00:00则在11:59:59把指令发送xplay)
* _id 该素材唯一标识符(调试使用)
* _index 该素材所使用的层(0-999)(层数越小越靠前,一般1-9层作为保留层,显示一些提示或者LOGO,通知等信息使用 ...)
* _content 素材存储路径
* _rect 素材显示位置与尺寸(素材可以任意缩放拉伸,任意坐标显示)
* _mode 屏幕模式(横屏:landscape、竖屏:portrait)
* _rotate 旋转角度(横屏:0,180、竖屏:90,270)
*/
public boolean playVideo(long _start, String _id, int _index, String _content, Rect _rect, String _mode,
int _rotate) {
Map<String, Object> data = new HashMap<String, Object>();
Map<String, Object> params = new HashMap<String, Object>();
data.put("id", _id);
data.put("type", "play");
data.put("start", _start);
data.put("libName", "video");
params.put("zIndex", _index);
params.put("path", _content);
params.put("left", _rect.x);
params.put("top", _rect.y);
params.put("width", _rect.width);
params.put("height", _rect.height);
params.put("screen_mode", _mode);
params.put("screen_rotate", _rotate);
data.put("params", params);
return this.playXplay(data);
}
/*
* 图片,参数使用与视频相同
*/
public boolean playImage(long _start, String _id, int _index, String _content, Rect _rect, String _mode,
int _rotate) {
Map<String, Object> data = new HashMap<String, Object>();
Map<String, Object> params = new HashMap<String, Object>();
data.put("id", _id);
data.put("type", "play");
data.put("start", _start);
data.put("libName", "pic");
params.put("zIndex", _index);
params.put("path", _content);
params.put("left", _rect.x);
params.put("top", _rect.y);
params.put("width", _rect.width);
params.put("height", _rect.height);
params.put("screen_mode", _mode);
params.put("screen_rotate", _rotate);
data.put("params", params);
return this.playXplay(data);
}
/*
* 二维码 _content 内容为二维码中的内容
*/
public boolean playQRCode(long _start, String _id, int _index, String _content, Rect _rect, String _mode,
int _rotate) {
Map<String, Object> data = new HashMap<String, Object>();
Map<String, Object> params = new HashMap<String, Object>();
data.put("id", _id);
data.put("type", "play");
data.put("start", _start);
data.put("libName", "qrcode");
params.put("zIndex", _index);
params.put("content", _content);
params.put("left", _rect.x);
params.put("top", _rect.y);
params.put("width", _rect.width);
params.put("height", _rect.height);
params.put("screen_mode", _mode);
params.put("screen_rotate", _rotate);
data.put("params", params);
return this.playXplay(data);
}
/*
* GIF,参数使用与视频相同
*/
public boolean playGIF(long _start, String _id, int _index, String _content, Rect _rect, String _mode,
int _rotate) {
Map<String, Object> data = new HashMap<String, Object>();
Map<String, Object> params = new HashMap<String, Object>();
data.put("id", _id);
data.put("type", "play");
data.put("start", _start);
data.put("libName", "gif");
params.put("zIndex", _index);
params.put("path", _content);
params.put("left", _rect.x);
params.put("top", _rect.y);
params.put("width", _rect.width);
params.put("height", _rect.height);
params.put("screen_mode", _mode);
params.put("screen_rotate", _rotate);
data.put("params", params);
return this.playXplay(data);
}
/*
* 信息提示框 _content 提示框内容
* _toast_type 提示框类型(notice、success、warning、error)
* _duration 提示框显示时间(如果为0则永久显示)
*/
public boolean playToast(long _start, String _id, int _index, String _content, String _mode, int _rotate,
String _toast_type, int _duration) {
Map<String, Object> data = new HashMap<String, Object>();
Map<String, Object> params = new HashMap<String, Object>();
data.put("id", _id);
data.put("type", "play");
data.put("start", _start);
data.put("libName", "toast");
params.put("zIndex", _index);
params.put("screen_mode", _mode);
params.put("screen_rotate", _rotate);
params.put("content", _content);
params.put("toast_type", _toast_type);
params.put("duration", _duration);
data.put("params", params);
return this.playXplay(data);
}
/*
* 摄像头
* _camera_width 与 _camera_height 为摄像头采集画面分辨率,建议(1280x720)
*/
public boolean playCamera(long _start, String _id, int _index, String _content, Rect _rect, String _mode,
int _rotate, int _camera_width, int _camera_height) {
Map<String, Object> data = new HashMap<String, Object>();
Map<String, Object> params = new HashMap<String, Object>();
data.put("id", _id);
data.put("type", "play");
data.put("start", _start);
data.put("libName", "camera");
params.put("zIndex", _index);
params.put("device", _content);
params.put("camera_width", _camera_width);
params.put("camera_height", _camera_height);
params.put("left", _rect.x);
params.put("top", _rect.y);
params.put("width", _rect.width);
params.put("height", _rect.height);
params.put("screen_mode", _mode);
params.put("screen_rotate", _rotate);
data.put("params", params);
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
专为树莓派(Raspberry Pi)设计的多媒体播放器且支持(Windows、Linux、Android)系统,支持视频、音频、流媒体、图片、摄像头、动画、文本、滚动字幕、日期时间、二维码、等,支持指令控制播放、覆盖、停止、移动、等,支持自定义分辨率、帧率(FPS),支持音频采样率自适应,支持多层、支持自定义布局,支持自定义位置与尺寸,支持视频帧与音轨或时钟同步,支持预加载,支持序列播放,支持无黑场切换,支持自定义字体,支持多种文本格式与样式,支持横竖屏旋转(0、180、90、270),支持自定义开始时间实现多台同步,支持屏幕快照
资源推荐
资源详情
资源评论
收起资源包目录
xplay-master.zip (96个子文件)
xplay-master
raspios
rpi_drm_install.sh 1KB
etc
00-xplay.conf 15B
simsun.ttc 17.37MB
log4qt.properties 370B
libs
rpi_drm
libSDL2-2.0.so.0.18.2 5.83MB
libSDL2-2.0.so.0 21B
libSDL2.so 21B
rpi
libswscale.so 21B
libswscale.so.5.9.100 390KB
libSDL2_net.so 24B
libSDL2_net-2.0.so.0 24B
libavutil.so.56.70.100 483KB
libSDL2_ttf-2.0.so.0.18.0 21.36MB
libavfilter.so 24B
libSDL2_ttf-2.0.so.0 25B
libavdevice.so 24B
libavutil.so.56 22B
libavdevice.so.58.13.100 47KB
libavformat.so.58.76.100 2.05MB
libavformat.so.58 24B
libavutil.so 22B
libavcodec.so 24B
libswscale.so.5 21B
libswresample.so.3.9.100 74KB
libavfilter.so.7.110.100 2.67MB
libswresample.so.3 24B
libavcodec.so.58.134.100 11.02MB
libavformat.so 24B
libavdevice.so.58 24B
libSDL2_net-2.0.so.0.0.1 61KB
libavfilter.so.7 24B
libavcodec.so.58 24B
libswresample.so 24B
libSDL2_ttf.so 25B
rpi_x11
libSDL2-2.0.so.0.18.2 6.88MB
libSDL2-2.0.so.0 21B
libSDL2.so 21B
bin
xplay 1.06MB
xplayctl 6.19MB
xplayrun 321B
rpi_x11_install.sh 1KB
raspios-legacy
etc
00-xplay.conf 15B
simsun.ttc 17.37MB
log4qt.properties 370B
libs
libswscale.so 21B
libswscale.so.5.9.100 398KB
libSDL2_net.so 24B
libSDL2_net-2.0.so.0 24B
libavutil.so.56.70.100 555KB
libSDL2_ttf-2.0.so.0.18.0 23.64MB
libavfilter.so 24B
libSDL2_ttf-2.0.so.0 25B
libavdevice.so 24B
libavutil.so.56 22B
libavdevice.so.58.13.100 59KB
libavformat.so.58.76.100 2.07MB
libavformat.so.58 24B
libavutil.so 22B
libavcodec.so 24B
libswscale.so.5 21B
libswresample.so.3.9.100 74KB
libSDL2-2.0.so.0.18.2 5.97MB
libavfilter.so.7.110.100 2.66MB
libSDL2-2.0.so.0 21B
libswresample.so.3 24B
libavcodec.so.58.134.100 11.01MB
libavformat.so 24B
libavdevice.so.58 24B
libSDL2_net-2.0.so.0.0.1 66KB
libavfilter.so.7 24B
libavcodec.so.58 24B
libswresample.so 24B
libSDL2.so 21B
libSDL2_ttf.so 25B
rpi_omx_install.sh 1KB
bin
xplay 1.05MB
xplayctl 6.19MB
xplayrun 321B
autotest
a2.jpg 161KB
a1_landscape.jpg 160KB
a1_portrait.jpg 337KB
autotest.sh 7KB
balloon.gif 473KB
yiyezi.mp4 4.86MB
uninstall.sh 162B
images
camera.jpg 84KB
layout.jpg 39KB
logo.jpg 487KB
demo.gif 2.08MB
example
xplayctl.go 12KB
example.go 3KB
example_x4_xplayctl.sh 2KB
example_x1_xplayctl.sh 832B
example.py 5KB
XplayCtl.java 12KB
Xplay.java 2KB
共 96 条
- 1
资源评论
Java程序员-张凯
- 粉丝: 1w+
- 资源: 7361
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功