cpview 播放添加延迟2秒
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.xscm.moduleutil.utils.roomview;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.text.TextUtils;
|
||||
@@ -41,8 +42,13 @@ import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.OkHttpClient;
|
||||
@@ -172,7 +178,6 @@ public class RoomCPView extends FrameLayout {
|
||||
avatarContainer1.setVisibility(View.VISIBLE);
|
||||
|
||||
|
||||
|
||||
// 启动头像上下浮动动画
|
||||
// startAvatarFloatAnimation();
|
||||
});
|
||||
@@ -299,9 +304,9 @@ public class RoomCPView extends FrameLayout {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* CP特效进来
|
||||
*
|
||||
* @param room_head1 头像1
|
||||
* @param room_head2 头像2
|
||||
* @param room_name1 名称1
|
||||
@@ -330,6 +335,7 @@ public class RoomCPView extends FrameLayout {
|
||||
}
|
||||
|
||||
queue.execute(new Runnable() {
|
||||
@SuppressLint("CheckResult")
|
||||
@Override
|
||||
public void run() {
|
||||
// 如果mp4Path不存在return
|
||||
@@ -355,9 +361,15 @@ public class RoomCPView extends FrameLayout {
|
||||
// 如果没有在加载则开始加载
|
||||
if (!isLoadEffect) {
|
||||
// 更改加载状态标记
|
||||
Observable.timer(2000, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<Long>() {
|
||||
@Override
|
||||
public void accept(Long aLong) throws Exception {
|
||||
isLoadEffect = true;
|
||||
loadStartAnimation();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
} finally {
|
||||
// 解锁
|
||||
lock.unlock();
|
||||
@@ -367,8 +379,6 @@ public class RoomCPView extends FrameLayout {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 原始的动画方法,现在只被内部调用
|
||||
*/
|
||||
@@ -378,7 +388,8 @@ public class RoomCPView extends FrameLayout {
|
||||
fadeIn.setDuration(500);
|
||||
fadeIn.setAnimationListener(new Animation.AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {}
|
||||
public void onAnimationStart(Animation animation) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
@@ -388,7 +399,8 @@ public class RoomCPView extends FrameLayout {
|
||||
fadeOut.setDuration(500);
|
||||
fadeOut.setAnimationListener(new Animation.AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {}
|
||||
public void onAnimationStart(Animation animation) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
@@ -398,14 +410,16 @@ public class RoomCPView extends FrameLayout {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {}
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
}
|
||||
});
|
||||
startAnimation(fadeOut);
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {}
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
}
|
||||
});
|
||||
startAnimation(fadeIn);
|
||||
}
|
||||
@@ -471,6 +485,7 @@ public class RoomCPView extends FrameLayout {
|
||||
|
||||
/**
|
||||
* 处理MP4文件,如果是网络URL则下载到本地
|
||||
*
|
||||
* @param path 文件路径或URL
|
||||
* @param callback 下载回调
|
||||
*/
|
||||
@@ -489,6 +504,7 @@ public class RoomCPView extends FrameLayout {
|
||||
|
||||
/**
|
||||
* 下载文件到本地
|
||||
*
|
||||
* @param url 下载URL
|
||||
* @param callback 下载回调
|
||||
*/
|
||||
@@ -623,11 +639,13 @@ public class RoomCPView extends FrameLayout {
|
||||
*/
|
||||
private interface DownloadCallback {
|
||||
void onSuccess(String localPath);
|
||||
|
||||
void onError(String error);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件扩展名
|
||||
*
|
||||
* @param url 文件URL
|
||||
* @return 文件扩展名
|
||||
*/
|
||||
@@ -713,7 +731,8 @@ public class RoomCPView extends FrameLayout {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {}
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
}
|
||||
});
|
||||
avatarsParentContainer.startAnimation(bottomUpAnimation);
|
||||
}
|
||||
@@ -765,6 +784,7 @@ public class RoomCPView extends FrameLayout {
|
||||
|
||||
/**
|
||||
* 开启或关闭特效视图
|
||||
*
|
||||
* @param isShow 是否显示
|
||||
*/
|
||||
public void openOrCloseEffectViewWith(boolean isShow) {
|
||||
@@ -779,6 +799,7 @@ public class RoomCPView extends FrameLayout {
|
||||
|
||||
/**
|
||||
* 下载并播放动画
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param playImage 动画URL
|
||||
* @param callback 下载回调
|
||||
|
||||
Reference in New Issue
Block a user