mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-04 10:32:39 +08:00
fix android isPlaying API
This commit is contained in:
@@ -28,17 +28,14 @@ import android.graphics.Rect;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.VideoView;
|
||||
|
||||
import org.cocos2dx.lib.Cocos2dxVideoView.OnVideoEventListener;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
||||
@@ -70,8 +67,6 @@ public class Cocos2dxVideoHelper {
|
||||
private final static int VideoTaskRestart = 10;
|
||||
private final static int VideoTaskKeepRatio = 11;
|
||||
private final static int VideoTaskFullScreen = 12;
|
||||
private final static int VideoTaskCurrentTime = 13;
|
||||
private final static int VideoTaskDuration = 14;
|
||||
final static int KeyEventBack = 1000;
|
||||
|
||||
static class VideoHandler extends Handler{
|
||||
@@ -393,10 +388,10 @@ public class Cocos2dxVideoHelper {
|
||||
Callable<Float> callable = new Callable<Float>() {
|
||||
@Override
|
||||
public Float call() throws Exception {
|
||||
Cocos2dxVideoView viedo = mVideoViews.get(index);
|
||||
Cocos2dxVideoView video = mVideoViews.get(index);
|
||||
float currentPosition = -1;
|
||||
if (viedo != null) {
|
||||
currentPosition = viedo.getCurrentPosition() / 1000.0f;
|
||||
if (video != null) {
|
||||
currentPosition = video.getCurrentPosition() / 1000.0f;
|
||||
}
|
||||
return new Float(currentPosition);
|
||||
}
|
||||
@@ -415,10 +410,10 @@ public class Cocos2dxVideoHelper {
|
||||
Callable<Float> callable = new Callable<Float>() {
|
||||
@Override
|
||||
public Float call() throws Exception {
|
||||
Cocos2dxVideoView viedo = mVideoViews.get(index);
|
||||
Cocos2dxVideoView video = mVideoViews.get(index);
|
||||
float duration = -1;
|
||||
if (viedo != null) {
|
||||
duration = viedo.getDuration() / 1000.0f;
|
||||
if (video != null) {
|
||||
duration = video.getDuration() / 1000.0f;
|
||||
}
|
||||
return new Float(duration);
|
||||
}
|
||||
@@ -433,6 +428,24 @@ public class Cocos2dxVideoHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isPlaying(final int index) {
|
||||
Callable<Boolean> callable = new Callable<Boolean>() {
|
||||
@Override
|
||||
public Boolean call() throws Exception {
|
||||
Cocos2dxVideoView video = mVideoViews.get(index);
|
||||
return video != null && video.isPlaying();
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
return callInMainThread(callable);
|
||||
} catch (ExecutionException e) {
|
||||
return false;
|
||||
} catch (InterruptedException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void setVideoVisible(int index, boolean visible) {
|
||||
Message msg = Message.obtain();
|
||||
|
||||
Reference in New Issue
Block a user