pk房完成,剩余禁止对方麦未完成

拍卖房完成
点歌房完成,音乐播放需要测试
This commit is contained in:
2025-07-04 16:38:21 +08:00
parent 4c7e996706
commit 2d510ffe2a
640 changed files with 698375 additions and 163954 deletions

View File

@@ -29,6 +29,7 @@ import com.liulishuo.okdownload.core.cause.EndCause;
import com.liulishuo.okdownload.core.cause.ResumeFailedCause;
import com.liulishuo.okdownload.core.listener.DownloadListener1;
import com.liulishuo.okdownload.core.listener.assist.Listener1Assist;
import com.opensource.svgaplayer.SVGACallback;
import com.opensource.svgaplayer.SVGADrawable;
import com.opensource.svgaplayer.SVGADynamicEntity;
import com.opensource.svgaplayer.SVGAImageView;
@@ -37,13 +38,17 @@ import com.opensource.svgaplayer.SVGAVideoEntity;
import com.qxcm.moduleutil.R;
import com.qxcm.moduleutil.databinding.RoomViewSvgaAnimBinding;
import com.qxcm.moduleutil.utils.Md5Utils;
import com.qxcm.moduleutil.utils.SpUtil;
import com.qxcm.moduleutil.utils.logger.Logger;
import com.tencent.bugly.idasc.crashreport.CrashReport;
import com.tencent.qgame.animplayer.AnimConfig;
import com.tencent.qgame.animplayer.inter.IAnimListener;
import com.tencent.qgame.animplayer.inter.IFetchResource;
import java.io.File;
import java.net.URL;
import java.util.LinkedList;
import java.util.Queue;
public class AvatarFrameView extends FrameLayout implements IAnimListener {
@@ -71,7 +76,10 @@ public class AvatarFrameView extends FrameLayout implements IAnimListener {
@Override
public void onVideoComplete() {
if (mType == 1) {
mBinding.playView.startPlay(mFile);
mBinding.playView.startPlay(mFile); // 循环播放
} else {
isPlaying = false;
playNextFromQueue(); // 播放下一项
}
}
@@ -92,6 +100,9 @@ public class AvatarFrameView extends FrameLayout implements IAnimListener {
private ChannelSplitRenderer1 renderer;
private int mType;//1:循环播放 2:播放一次停止播放
private File mFile;
private final Queue<PlayItem> playQueue = new LinkedList<>();
private boolean isPlaying = false;
private RoomViewSvgaAnimBinding mBinding;
@@ -136,23 +147,85 @@ public class AvatarFrameView extends FrameLayout implements IAnimListener {
mBinding.playView.setAnimListener(this);
}
public void setSource(String url, RenderType type, int type2) {
clearPrevious();
renderType = type;
mType = type2;
switch (type) {
case SVGA:
mBinding.playView.stopPlay();
mBinding.playView.setVisibility(View.GONE);
loadSVGA(url);
break;
case MP4:
// loadMP4(url);
mBinding.playView.setVisibility(View.VISIBLE);
downloadAndPlayMp4(url);
break;
private String getFileExtension(String url) {
if (url == null || url.isEmpty()) return "";
int dotIndex = url.lastIndexOf(".");
if (dotIndex > 0 && dotIndex < url.length() - 1) {
return url.substring(dotIndex + 1).toLowerCase(); // 返回 "mp4", "svga" 等
}
return "";
}
private void playNextFromQueue() {
PlayItem item = playQueue.poll();
if (item != null) {
isPlaying = true;
RenderType type = null;
String ext = getFileExtension(item.url);
if ("svga".equalsIgnoreCase(ext)) {
type = RenderType.SVGA;
} else if ("mp4".equalsIgnoreCase(ext)) {
type = RenderType.MP4;
}
if (type == null) {
isPlaying = false;
playNextFromQueue(); // 跳过无效项
return;
}
clearPrevious();
renderType = type;
mType = item.type;
switch (type) {
case SVGA:
mBinding.playView.stopPlay();
mBinding.playView.setVisibility(View.GONE);
loadSVGA(item.url);
break;
case MP4:
mBinding.playView.setVisibility(View.VISIBLE);
downloadAndPlayMp4(item.url);
break;
}
} else {
isPlaying = false;
}
}
public void setSource(String url, int type2) {
if (SpUtil.getOpenEffect()==1) {
playQueue.offer(new PlayItem(url, type2));
if (!isPlaying) {
playNextFromQueue();
}
}else {
playQueue.clear();
isPlaying = false;
}
// RenderType type = null;
// if ("svga".equalsIgnoreCase(getFileExtension(url))){
// type = RenderType.SVGA;
// }else if ("mp4".equalsIgnoreCase(getFileExtension(url))){
// type = RenderType.MP4;
// }
//
// clearPrevious();
// renderType = type;
// mType = type2;
// switch (type) {
// case SVGA:
// mBinding.playView.stopPlay();
// mBinding.playView.setVisibility(View.GONE);
// loadSVGA(url);
// break;
// case MP4:
//// loadMP4(url);
// mBinding.playView.setVisibility(View.VISIBLE);
// downloadAndPlayMp4(url);
// break;
// }
}
private void downloadAndPlayMp4(String url) {
@@ -222,11 +295,44 @@ public class AvatarFrameView extends FrameLayout implements IAnimListener {
public void onComplete(SVGAVideoEntity videoItem) {
SVGADrawable drawable = new SVGADrawable(videoItem, new SVGADynamicEntity());
svgaSurface.setImageDrawable(drawable);
svgaSurface.setCallback(new SVGACallback() {
@Override
public void onStep(int i, double v) {
}
@Override
public void onRepeat() {
}
@Override
public void onPause() {
}
@Override
public void onFinished() {
isPlaying = false;
playNextFromQueue();
}
});
// svgaSurface.setCallback(new SVGAImageViewCallback() {
// @Override
// public void onAnimationFinished() {
// isPlaying = false;
// playNextFromQueue();
// }
// });
svgaSurface.startAnimation();
}
@Override
public void onError() {
isPlaying = false;
playNextFromQueue();
}
});
} catch (Exception e) {
@@ -264,10 +370,10 @@ public class AvatarFrameView extends FrameLayout implements IAnimListener {
}
private void clearPrevious() {
if (exoPlayer != null) {
exoPlayer.stop();
exoPlayer.clearVideoSurface();
}
// if (exoPlayer != null) {
// exoPlayer.stop();
// exoPlayer.clearVideoSurface();
// }
if (svgaSurface.getDrawable() instanceof SVGADrawable) {
((SVGADrawable) svgaSurface.getDrawable()).stop();
@@ -276,13 +382,13 @@ public class AvatarFrameView extends FrameLayout implements IAnimListener {
if (playerView != null) playerView.setVisibility(View.GONE);
if (svgaSurface != null) svgaSurface.setVisibility(View.GONE);
// if (glSurfaceView != null) glSurfaceView.setVisibility(View.GONE);
mBinding.playView.setVisibility(View.GONE);
// mBinding.playView.setVisibility(View.GONE);
}
public void release() {
if (exoPlayer != null) {
exoPlayer.release();
}
// if (exoPlayer != null) {
// exoPlayer.release();
// }
if (svgaSurface.getDrawable() instanceof SVGADrawable) {
((SVGADrawable) svgaSurface.getDrawable()).stop();
@@ -293,4 +399,32 @@ public class AvatarFrameView extends FrameLayout implements IAnimListener {
// glSurfaceView.requestRender();
}
}
public void clearQueue() {
playQueue.clear();
isPlaying = false;
}
private static class PlayItem {
String url;
int type;
PlayItem(String url, int type) {
this.url = url;
this.type = type;
}
}
/**
* 关闭特效
*/
public void closeEffect() {
//清空队列
playQueue.clear();
//关闭动画
// if (mBinding.image != null && isPlaying && mBinding.image.isAnimating()) {
// mBinding.image.setAnimation(null);
// mBinding.image.clearAnimation();
// mBinding.image.stopAnimation();
// }
}
}