视屏按照后台下发的模块(片段节点)快进或快退
protected void prev() {
isFastSeeking = true;
if (isLoopSegmeng) {
isLoopSegmeng = false;
playMenuView.setPlayLoopSegmengBackgroud(isLoopSegmeng);
}
int position = playEngine.getPosition();
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
SquareDanceModel m = list.get(i);
{
if (position <= (m.getEnd() * 1000) && position >= (m.getStart() * 1000)) {
playSegmengIndex--;
if (playSegmengIndex < 0) {
playSegmengIndex = 0;
}
playEngine.seekPlay(list.get(playSegmengIndex).getStart() * 1000);
isSwitchNext = 1;
}
}
}
}
// int position = playEngine.getPlayer().getPosition() - onceSpeedLength;
// int position;
// //TODO posion 获取seekbar当前进度
// position = playMenuView.getPlayProcess() - onceSpeedLength;
// playMenuView.onPlayProcess(position);
// handler.removeCallbacks(mSeekListenerRunnable);
// handler.postDelayed(mSeekListenerRunnable, 1000);
//
if (playEngine.getPlayStatus() == PlayStatus.pause) {
playEngine.resumePlay();
}
// int position = playEngine.getPlayer().getPosition() - onceSpeedLength;
// playEngine.seekPlay(position);
}
/**
* 分段播放呢时间索引
*/
private ArrayList<SquareDanceModel> list;
@Override
public void parseJson(IJson json) {
if (json.has("online")) {
IJson onlineJson = json.getJson("online");
if (onlineJson.has("url")) {
try {
url = onlineJson.getString("url");
JSONArray urlarr = new JSONArray(url);
if (urlarr.length() > 0) {
url = (String) urlarr.get(0);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
if (onlineJson.has("lastTime")){
lastTime = onlineJson.getInt("lastTime");
}
if (onlineJson.has("size")){
size = onlineJson.getInt("size");
}
}
后台下发数据,解析
private int lastTime;
//节点类型 1.前奏 2 正面 3 背面 4、慢节奏拍子 5.舞蹈小常识 6.广告 7 结尾
private ArrayList<SquareDanceModel> list;
if (json.has("noteList")){
IJson[] jsonArray = json.getJsonArray("noteList");
if (jsonArray.length > 0) {
list = new ArrayList<SquareDanceModel>();
for (int i = 0; i< jsonArray.length; i ++) {
SquareDanceModel mode = new SquareDanceModel();
mode.parseJson(jsonArray[i]);
//节点类型 1.前奏 2 正面 3 背面 4、慢节奏拍子 5.舞蹈小常识 6.广告 7 结尾
if (!mode.isAd()){
list.add(mode);
}
}
}
}
if (list != null){
doSquareDanceModel(list);
}
if (json.has("url")) { // 购买会员的url
this.url = json.getString("url");
}
}
/**
* 排序
* @param list
*/
protected void doSquareDanceModel(ArrayList<SquareDanceModel> list) {
Collections.sort(list, new Comparator<SquareDanceModel>() {
@Override
public int compare(SquareDanceModel model1, SquareDanceModel model2) {
if (model1.getStart() < model2.getStart()) {
return -1;
} else if (model1.getStart() > model2.getStart()) {
return 1;
}
return 0;
}
});
}
监听当前点击
public interface SquareDanceMenuListener {
void onPlayBtnClicked();
void onNextBtnClicked();
void onPrevBtnClicked();
void onLoopSegmentBtnClicked();
void onFavorateBtnClicked();
}
@Override
public void onClick(IUIViewBase arg0) {
if (!Utils.isCanClick(getContext(), 500)) {
return;
}
if (!NetworkUtils.isNetworkValidate(getContext())) {
ToastUtils.showToast(getContext(), R.string.uitext_network_disconnection);
return;
}
if (arg0 == preSegmentBtn) {// 上一段
if (listener != null) {
listener.onPrevBtnClicked();
}
} else if (arg0 == nextSegmentBtn) {
if (listener != null) {
listener.onNextBtnClicked();
}
} else if (arg0 == playPauseBtn) {
if (listener != null) {
listener.onPlayBtnClicked();
}
} else if (arg0 == loopSegmentBtn) {
if (listener != null) {
listener.onLoopSegmentBtnClicked();
}
} else if (arg0 == favorateBtn) {
if (listener != null) {
listener.onFavorateBtnClicked();
}
}
}