This commit is contained in:
blank
2021-06-07 15:13:32 +08:00
parent 74d5947e9d
commit 346fc42e67
500 changed files with 77303 additions and 1 deletions

View File

@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cx3.blank.demo"
android:installLocation="auto">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.CAMERA"/>
<application
android:allowBackup="true"
android:label="@string/app_name"
android:usesCleartextTraffic="true"
android:icon="@mipmap/ic_launcher">
<meta-data android:name="android.app.lib_name"
android:value="cocos" />
<!-- 高德定位 -->
<meta-data
android:name="com.amap.api.v2.apikey"
android:value="418378a88b3e94a77fa3548b5b43afc0" />
<service android:name="com.amap.api.location.APSService"></service>
<activity
android:name=".AppActivity"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden|screenSize|screenLayout"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar"
android:launchMode="singleTask"
android:taskAffinity="" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.cocos.lib.CocosEditBoxActivity"
android:configChanges="orientation|keyboardHidden|screenSize|screenLayout"
android:screenOrientation="behind"
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
</application>
</manifest>

View File

@@ -0,0 +1,69 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger()
buildToolsVersion PROP_BUILD_TOOLS_VERSION
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "cx3.blank.demo"
minSdkVersion PROP_MIN_SDK_VERSION
targetSdkVersion PROP_TARGET_SDK_VERSION
versionCode 1
versionName "1.0"
}
packagingOptions {
exclude 'META-INF/LICENSE'
}
sourceSets.main {
manifest.srcFile "AndroidManifest.xml"
java.srcDirs "src"
res.srcDirs "res"
jniLibs.srcDirs = ["libs", "../../../../cx-framework3.1/cocos3-libs/cocos3-libso/build/app/intermediates/cmake/release/obj"]
assets.srcDirs = ['../../assets', '../../boot', '../../statics']
}
signingConfigs {
release {
if (project.hasProperty("RELEASE_STORE_FILE")) {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
}
}
}
buildTypes {
release {
debuggable false
jniDebuggable false
renderscriptDebuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
if (project.hasProperty("RELEASE_STORE_FILE")) {
signingConfig signingConfigs.release
}
}
debug {
debuggable true
jniDebuggable true
renderscriptDebuggable true
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
implementation project(':libcc')
implementation 'com.amap.api:location:latest.integration'
// implementation 'com.android.support:appcompat-v7:28.0.0'
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

View File

@@ -0,0 +1,50 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in E:\developSoftware\Android\SDK/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Proguard Cocos2d-x-lite for release
-keep public class com.cocos.** { *; }
-dontwarn com.cocos.**
# Proguard Apache HTTP for release
-keep class org.apache.http.** { *; }
-dontwarn org.apache.http.**
# Proguard okhttp for release
-keep class okhttp3.** { *; }
-dontwarn okhttp3.**
-keep class okio.** { *; }
-dontwarn okio.**
# Proguard Android Webivew for release. you can comment if you are not using a webview
-keep public class android.net.http.SslError
-keep public class android.webkit.WebViewClient
-dontwarn android.webkit.WebView
-dontwarn android.net.http.SslError
-dontwarn android.webkit.WebViewClient
# keep anysdk for release. you can comment if you are not using anysdk
-keep public class com.anysdk.** { *; }
-dontwarn com.anysdk.**
# amapLocation
-keep class com.amap.api.location.**{*;}
-keep class com.amap.api.fence.**{*;}
-keep class com.loc.**{*;}
-keep class com.autonavi.aps.amapapi.model.**{*;}

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 425 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 610 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#60A7C6FC">
<FrameLayout
android:id="@+id/contentView"
android:layout_width="157dp"
android:layout_height="561dp" android:background="#ff0000FC" android:clipChildren="false" android:clipToPadding="false">
<FrameLayout
android:id="@+id/contentView1"
android:layout_width="355dp"
android:layout_height="517dp" android:background="#FC5800">
<view android:layout_width="285dp" android:layout_height="354dp">
<view android:layout_width="222dp" android:layout_height="222dp">
</view>
</view>
<EditText
android:id="@+id/editText"
android:layout_width="283dp"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="dddddddddddddddddddddddddddddddddddddaa"/>
</FrameLayout>
</FrameLayout>
</FrameLayout>

View File

@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="vertical" >
<!--android:background="@color/mediacontroller_bg"-->
<!--<LinearLayout-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:visibility="visible"-->
<!--android:orientation="horizontal" >-->
<!--<TextView-->
<!--android:id="@+id/mediacontroller_time_current"-->
<!--style="@style/MediaController_Text"-->
<!--android:layout_width="fill_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_marginLeft="30dp"-->
<!--android:layout_weight="1"-->
<!--android:text="00:00" />-->
<!--<TextView-->
<!--android:id="@+id/mediacontroller_time_total"-->
<!--style="@style/MediaController_Text"-->
<!--android:layout_width="fill_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_marginRight="30dp"-->
<!--android:layout_weight="1"-->
<!--android:gravity="right"-->
<!--android:text="22:33" />-->
<!--</LinearLayout>-->
<!--<RelativeLayout-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:orientation="horizontal" >-->
<!--<ImageButton-->
<!--android:id="@+id/mediacontroller_play_pause"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_centerVertical="true"-->
<!--android:layout_marginLeft="5dp"-->
<!--android:background="@drawable/mediacontroller_button"-->
<!--android:contentDescription="@string/mediacontroller_play_pause"-->
<!--android:src="@drawable/mediacontroller_pause" />-->
<!--<ImageButton-->
<!--android:id="@+id/mediacontroller_play_fs"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_alignParentRight="true"-->
<!--android:layout_centerVertical="true"-->
<!--android:background="@drawable/mediacontroller_change_size"-->
<!--android:visibility="visible" />-->
<!--<org.cocos2dx.lib.MySeekBar-->
<!--android:id="@+id/mediacontroller_seekbar"-->
<!--style="@style/MediaController_SeekBar"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_centerVertical="true"-->
<!--android:layout_toLeftOf="@id/mediacontroller_play_fs"-->
<!--android:layout_toRightOf="@id/mediacontroller_play_pause"-->
<!--android:focusable="true"-->
<!--android:max="1000" />-->
<!--</RelativeLayout>-->
<!--<TextView-->
<!--android:id="@+id/mediacontroller_file_name"-->
<!--style="@style/MediaController_Text"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_marginLeft="5dp"-->
<!--android:ellipsize="marquee"-->
<!--android:singleLine="true" />-->
</LinearLayout>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#FFFFFF</color>
</resources>

View File

@@ -0,0 +1,3 @@
<resources>
<string name="app_name" translatable="false">cx-demo</string>
</resources>

View File

@@ -0,0 +1,49 @@
package cx3.blank.demo;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import com.cocos.lib.CocosActivity;
import cx3.blank.sdk.JsIntf;
public class AppActivity extends CocosActivity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
if (!isTaskRoot())
{
return;
}
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
{
mFrameLayout.setFitsSystemWindows(false);
Window window = getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
| WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(Color.TRANSPARENT);
window.setNavigationBarColor(Color.TRANSPARENT);
}
app = this;
JsIntf.init();
}
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] paramArrayOfInt)
{
PermsissionClass.onRequestPermissionsResult(requestCode, permissions, paramArrayOfInt);
}
}

View File

@@ -0,0 +1,106 @@
package cx3.blank.demo;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class PermsissionClass
{
private static int mapMngRequestCode = 100;
private static Map<Integer, PermsissionReq> mapReq = new HashMap<>();
public interface PermsissionInterface
{
void checkPermissionCallback(int requestCode, boolean granted);
}
public static int makeRequestCode()
{
return ++mapMngRequestCode;
}
///////检查是否有权限并申请
public static void checkPermission(Context context, PermsissionInterface intf, int requestCode, String[] permissions)
{
PermsissionReq req = mapReq.get(requestCode);
if (req != null)
{
intf.checkPermissionCallback(requestCode, req.granted);
return;
}
if (Build.VERSION.SDK_INT < 23)
{
intf.checkPermissionCallback(requestCode, true);
return;
}
try
{
List<String> needRequestPermissonList = new ArrayList<>();
for (String perm : permissions)
{
if (context.getApplicationInfo().targetSdkVersion >= 23)
{
Method checkSelfMethod = context.getClass().getMethod("checkSelfPermission", String.class);
Method shouldShowRequestPermissionRationaleMethod = context.getClass().getMethod("shouldShowRequestPermissionRationale", String.class);
if ((Integer) checkSelfMethod.invoke(context, perm) != PackageManager.PERMISSION_GRANTED || (Boolean) shouldShowRequestPermissionRationaleMethod.invoke(context, perm))
needRequestPermissonList.add(perm);
}
// else
// {
// if (PermissionChecker.checkSelfPermission(context, perm) != PackageManager.PERMISSION_GRANTED)
// needRequestPermissonList.add(perm);
// }
}
if (needRequestPermissonList.size() == 0)
{
intf.checkPermissionCallback(requestCode, true);
return;
}
req = new PermsissionReq();
req.intf = intf;
req.granted = false;
mapReq.put(requestCode, req);
String[] array = needRequestPermissonList.toArray(new String[needRequestPermissonList.size()]);
Method method = context.getClass().getMethod("requestPermissions", new Class[]{String[].class, int.class});
method.invoke(context, array, requestCode);
} catch (Throwable e)
{
}
}
public static void onRequestPermissionsResult(int requestCode, String[] permissions, int[] paramArrayOfInt)
{
boolean granted = true;
for (int result : paramArrayOfInt)
{
if (result != PackageManager.PERMISSION_GRANTED)
{
granted = false;
break;
}
}
PermsissionReq req = mapReq.get(requestCode);
if (req != null)
{
req.granted = granted;
req.intf.checkPermissionCallback(requestCode, granted);
}
}
}
class PermsissionReq
{
public PermsissionClass.PermsissionInterface intf;
public boolean granted;
}

View File

@@ -0,0 +1,26 @@
package cx3.blank.sdk;
import cx.NativeIntf;
import cx.NativeParams;
import cx3.blank.sdk.system.SystemIntf;
import cx3.blank.sdk.video.VideoIntf;
public class JsIntf
{
public static void init()
{
NativeIntf.setJsIntf(JsIntf::call);
}
public static String call(NativeParams params)
{
String classname = params.classname;
if (classname.equals("system"))
return SystemIntf.ins().call(params);
if (classname.equals("video"))
return VideoIntf.ins().call(params);
return "";
}
}

View File

@@ -0,0 +1,63 @@
package cx3.blank.sdk.system;
import android.Manifest;
import android.content.Intent;
import android.net.Uri;
import com.cocos.lib.CocosActivity;
import cx.NativeParams;
import cx3.blank.demo.PermsissionClass;
public class SystemIntf
{
private static SystemIntf s_sharedSystemIntf = null;
public static SystemIntf ins()
{
if (s_sharedSystemIntf == null)
s_sharedSystemIntf = new SystemIntf();
return s_sharedSystemIntf;
}
public String call(NativeParams params)
{
String fname = params.fname;
if (fname.equals("callPhone"))
checkPermission(fname, params);
return "";
}
private final int permissionRequestCode = PermsissionClass.makeRequestCode();
private final String[] permissions = {
Manifest.permission.CALL_PHONE
};
private void checkPermission(String fname, NativeParams params)
{
PermsissionClass.checkPermission(CocosActivity.app, new PermsissionClass.PermsissionInterface()
{
@Override
public void checkPermissionCallback(int requestCode, boolean granted)
{
if (granted)
{
if (fname.equals("callPhone"))
callPhone(params.at(0).asString());
}
}
}, permissionRequestCode, permissions);
}
private void callPhone(String phone)
{
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phone));
try
{
CocosActivity.app.startActivity(intent);
}
catch (SecurityException e)
{
}
}
}

View File

@@ -0,0 +1,184 @@
package cx3.blank.sdk.video;
import android.view.View;
import android.widget.FrameLayout;
import com.cocos.lib.CocosActivity;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import cx.NativeParams;
import cx.mask.MaskIntf;
public class VideoIntf
{
private static VideoIntf s_sharedVideoIntf = null;
public static VideoIntf ins()
{
if (s_sharedVideoIntf == null)
s_sharedVideoIntf = new VideoIntf();
return s_sharedVideoIntf;
}
private Map<String, VideoView> videoMap = new HashMap();
private Map<String, ArrayList<NativeParams>> taskMap = new HashMap();
//创建video是在UI线程线程未完成时立即调用其他方法就取不到video因此用队列处理请求每一个video一个任务队列
public String call(NativeParams params)
{
String videoName = params.at(0).asString();
ArrayList<NativeParams> taskList = taskMap.get(videoName);
if (taskList == null)
{
taskList = new ArrayList();
taskMap.put(videoName, taskList);
}
taskList.add(params);
executeTask(taskList);
return "";
}
private void executeTask(ArrayList<NativeParams> taskList)
{
if (taskList.size() == 0)
return;
CocosActivity.app.runOnUiThread(new Runnable()
{
@Override
public void run()
{
while (taskList.size() > 0)
{
NativeParams params = taskList.remove(0);
callInternal(params);
}
}
});
}
public String callInternal(NativeParams params)
{
String fname = params.fname;
//删除指定maskView中的所有videoView
if (fname.equals("removeInMask"))
{
String maskName = params.at(0).asString();
removeInMask(maskName);
return "";
}
String videoName = params.at(0).asString();
if (fname.equals("createInMask"))
{
String maskName = params.at(1).asString();
float rectX = params.at(2).asFloat();
float rectY = params.at(3).asFloat();
float rectW = params.at(4).asFloat();
float rectH = params.at(5).asFloat();
createInMask(videoName, maskName, rectX, rectY, rectW, rectH);
return "";
}
else if (fname.equals("create"))
{
float rectX = params.at(1).asFloat();
float rectY = params.at(2).asFloat();
float rectW = params.at(3).asFloat();
float rectH = params.at(4).asFloat();
create(videoName, rectX, rectY, rectW, rectH);
return "";
}
VideoView videoView = videoMap.get(videoName);
if (videoView == null)
return "";
if (fname.equals("play"))
videoView.play(params.at(1).asString());
else if (fname.equals("setRoundRadius"))
videoView.setRoundRadius(params.at(1).asInt());
else if (fname.equals("setPosition"))
videoView.setPosition(Math.round(params.at(1).asFloat()), Math.round(params.at(2).asFloat()));
else if (fname.equals("setFullScreen"))
videoView.setFullScreen(params.at(1).asBool());
else if (fname.equals("pause"))
{
videoView.pausePlay();
if (params.at(1).asBool())
videoView.setVisibility(View.INVISIBLE);
}
else if (fname.equals("resume"))
{
videoView.startPlay();
if (videoView.getVisibility() == View.INVISIBLE)
videoView.setVisibility(View.VISIBLE);
}
else if (fname.equals("seekToTime"))
videoView.seekTo(params.at(1).asInt()); //seconds
else if (fname.equals("lockSeek"))
videoView.lockSeek(params.at(1).asBool());
else if (fname.equals("showBar"))
videoView.showBar(params.at(1).asBool());
else if (fname.equals("removeVideo"))
{
videoMap.remove(videoName);
taskMap.remove(videoName);
videoView.close();
}
return "";
}
public void createInMask(String videoName, String maskName, final float rectX, final float rectY, final float rectW, final float rectH)
{
if (videoMap.get(videoName) != null)
return;
FrameLayout.LayoutParams lParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
lParams.leftMargin = Math.round(rectX);
lParams.topMargin = Math.round(rectY);
lParams.width = Math.round(rectW);
lParams.height = Math.round(rectH);
VideoView videoView = new VideoView(lParams);
if (maskName != null)
MaskIntf.ins().addNativeView(maskName, videoView, videoName, lParams);
else
CocosActivity.app.getFrameLayout().addView(videoView, 0, lParams);
videoMap.put(videoName, videoView);
}
public void create(String videoName, float rectX, float rectY, float rectW, float rectH)
{
createInMask(videoName, null, rectX, rectY, rectW, rectH);
}
public void removeInMask(final String maskName)
{
for (Iterator<Entry<String, VideoView>> it = videoMap.entrySet().iterator(); it.hasNext(); )
{
Entry<String, VideoView> item = it.next();
String videoName = item.getKey();
VideoView videoView = item.getValue();
it.remove();
taskMap.remove(videoName);
videoView.close();
}
}
}

View File

@@ -0,0 +1,383 @@
package cx3.blank.sdk.video;
import android.app.Activity;
import android.app.Service;
import android.content.pm.ActivityInfo;
import android.content.res.AssetFileDescriptor;
import android.graphics.Canvas;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.RectF;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.net.Uri;
import android.opengl.GLSurfaceView;
import android.view.SurfaceHolder;
import android.widget.FrameLayout;
import android.widget.MediaController;
import com.cocos.lib.CocosActivity;
import cx.sys.SysIntf;
public class VideoView extends GLSurfaceView implements SurfaceHolder.Callback,
MediaController.MediaPlayerControl,
MediaPlayer.OnPreparedListener,
MediaPlayer.OnErrorListener
{
public static final int CB_COMPLETED = 1;
public static final int CB_ERROR = 2;
private Rect layoutRect = new Rect();
private String url = null;
private boolean isFullScreen = false;
private boolean isMute = false;
private boolean paused = false;
private boolean lockSeek = false;
private int roundRadius = 0;
private Activity activity;
private MediaPlayer mediaPlayer;
private MediaController controller;
private VideoViewInterface videoViewInterface = null;
private int mCurrentBufferPercentage = 0;
private static final String assetRoot = "@assets/";
public VideoView(FrameLayout.LayoutParams lParams)
{
super(CocosActivity.app, null);
this.activity = CocosActivity.app;
layoutRect.left = lParams.leftMargin;
layoutRect.top = lParams.topMargin;
layoutRect.right = lParams.width;
layoutRect.bottom = lParams.height;
getHolder().addCallback(this);
setKeepScreenOn(true);
setFocusable(true);
setFocusableInTouchMode(true);
mediaPlayer = new MediaPlayer();
mediaPlayer.setOnPreparedListener(this);
mediaPlayer.setOnBufferingUpdateListener(bufferingUpdateListener);
mediaPlayer.setOnCompletionListener(completionListener);
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setScreenOnWhilePlaying(true);
//todo: controller ui
controller = new MediaController(CocosActivity.app);
controller.setAnchorView((FrameLayout)this.getParent());
//todo: video mask
// setWillNotDraw(false);
}
// @Override
// public void draw(Canvas canvas)
// {
// canvas.clipRect(new RectF(50, 50, 100, 100));
// super.draw(canvas);
// }
public void setPlayCallback(VideoViewInterface videoViewInterface)
{
this.videoViewInterface = videoViewInterface;
}
public interface VideoViewInterface
{
void callback(int flag, String value);
}
public void play(String url)
{
try
{
if (this.url != null)
{
mediaPlayer.pause();
mediaPlayer.reset();
}
this.url = url;
if (url.startsWith(assetRoot))
{
AssetFileDescriptor assetFileDescriptor = activity.getAssets().openFd(url.substring(assetRoot.length()));
mediaPlayer.setDataSource(assetFileDescriptor.getFileDescriptor(), assetFileDescriptor.getStartOffset(), assetFileDescriptor.getLength());
}
/*
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && url.charAt(0) == '/')
{
Uri uri = FileProvider.getUriForFile(activity, activity.getPackageName() + ".fileProvider", new File(url));
mediaPlayer.setDataSource(activity, uri);
}
*/
else if (url.startsWith("http"))
mediaPlayer.setDataSource(activity, Uri.parse(url));
else
{
AssetFileDescriptor assetFileDescriptor = activity.getAssets().openFd(url);
mediaPlayer.setDataSource(assetFileDescriptor.getFileDescriptor(), assetFileDescriptor.getStartOffset(), assetFileDescriptor.getLength());
}
mediaPlayer.prepareAsync();
}
catch (Exception e)
{
e.printStackTrace();
}
}
public void close()
{
if (mediaPlayer != null)
{
mediaPlayer.stop();
mediaPlayer.reset();
mediaPlayer.release();
mediaPlayer = null;
}
FrameLayout parent = (FrameLayout)getParent();
parent.removeView(this);
}
public void setFullScreen(boolean fullScreen)
{
if (isFullScreen == fullScreen)
return;
isFullScreen = fullScreen;
updateLayout();
}
public void updateLayout()
{
if (isFullScreen)
{
Point screenSize = SysIntf.getScreenSize();
FrameLayout.LayoutParams lParams = (FrameLayout.LayoutParams) this.getLayoutParams();
lParams.leftMargin = 0;
lParams.topMargin = 0;
lParams.width = screenSize.y;
lParams.height = screenSize.x;
this.setLayoutParams(lParams);
// CocosActivity.app.getFrameLayout().addView(this, lParams);
// CocosActivity.app.setRequestedOrientation(params.fullScreen ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
CocosActivity.app.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
else
{
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) this.getLayoutParams();
layoutParams.leftMargin = this.layoutRect.left;
layoutParams.topMargin = this.layoutRect.top;
layoutParams.width = this.layoutRect.right;
layoutParams.height = this.layoutRect.bottom;
this.setLayoutParams(layoutParams);
}
}
public void setPosition(int x, int y)
{
layoutRect.left = x;
layoutRect.top = y;
if (!isFullScreen)
{
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) this.getLayoutParams();
layoutParams.leftMargin = x;
layoutParams.topMargin = y;
this.setLayoutParams(layoutParams);
}
}
public void setRoundRadius(int radius)
{
this.roundRadius = radius;
}
public void seekToTime(int seconds)
{
}
public void lockSeek(boolean value)
{
this.lockSeek = value;
}
public void showBar(boolean value)
{
// playerBar = new MediaPlayerBar(this);
}
public void setMute(boolean mute)
{
if (this.isMute == mute)
return;
this.isMute = mute;
if (mediaPlayer == null)
return;
if (mute)
mediaPlayer.setVolume(0, 0);
else
{
AudioManager audioManager = (AudioManager)activity.getSystemService(Service.AUDIO_SERVICE);
int current = audioManager.getStreamVolume( AudioManager.STREAM_MUSIC );
mediaPlayer.setVolume(current, current);
}
}
public void startPlay()
{
this.paused = false;
if (mediaPlayer != null)
mediaPlayer.start();
}
public void pausePlay()
{
this.paused = true;
if (mediaPlayer != null)
mediaPlayer.pause();
}
@Override
public void start()
{
if (mediaPlayer != null)
mediaPlayer.start();
}
public void stop()
{
if (mediaPlayer != null)
mediaPlayer.stop();
}
@Override
public void pause()
{
if (mediaPlayer != null)
mediaPlayer.pause();
}
@Override
public int getDuration()
{
return mediaPlayer != null ? mediaPlayer.getDuration() : 0;
}
@Override
public int getCurrentPosition()
{
return mediaPlayer != null ? mediaPlayer.getCurrentPosition() : 0;
}
@Override
public void seekTo(int pos)
{
if (mediaPlayer != null)
mediaPlayer.seekTo(pos);
}
@Override
public boolean isPlaying()
{
return mediaPlayer != null && mediaPlayer.isPlaying();
}
@Override
public int getBufferPercentage()
{
return mCurrentBufferPercentage;
}
@Override
public boolean canPause()
{
return true;
}
@Override
public boolean canSeekBackward()
{
return !lockSeek;
}
@Override
public boolean canSeekForward()
{
return !lockSeek;
}
@Override
public int getAudioSessionId()
{
return mediaPlayer.getAudioSessionId();
}
@Override
public void onPrepared(MediaPlayer mediaPlayer)
{
if (mediaPlayer != null)
{
this.updateLayout();
mediaPlayer.start();
}
}
@Override
public boolean onError(MediaPlayer mediaPlayer, int what, int extra)
{
if (videoViewInterface != null)
videoViewInterface.callback(CB_ERROR, null);
return false;
}
private MediaPlayer.OnBufferingUpdateListener bufferingUpdateListener = new MediaPlayer.OnBufferingUpdateListener()
{
public void onBufferingUpdate(MediaPlayer mp, int percent)
{
mCurrentBufferPercentage = percent;
}
};
private MediaPlayer.OnCompletionListener completionListener = new MediaPlayer.OnCompletionListener()
{
public void onCompletion(MediaPlayer mp)
{
if (videoViewInterface != null)
videoViewInterface.callback(CB_COMPLETED, null);
}
};
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h)
{
if (mediaPlayer != null)
mediaPlayer.setDisplay(holder);
}
@Override
public void surfaceCreated(SurfaceHolder holder)
{
//返回至前台时继续播放
if (mediaPlayer != null)
{
mediaPlayer.setDisplay(holder);
if (!paused)
mediaPlayer.start();
}
}
@Override
public void surfaceDestroyed(SurfaceHolder holder)
{
if (mediaPlayer == null)
return;
//切换至后台时暂停
if (mediaPlayer.isPlaying())
mediaPlayer.pause();
}
}

View File

@@ -0,0 +1,30 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
flatDir {
dirs 'libs'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

View File

@@ -0,0 +1,26 @@
android.injected.testOnly=false
# Android SDK version that will be used as the compile project
PROP_COMPILE_SDK_VERSION=28
# Android SDK version that will be used as the earliest version of android this application can run on
PROP_MIN_SDK_VERSION=21
# Android SDK version that will be used as the latest version of android this application has been tested on
PROP_TARGET_SDK_VERSION=27
# Android Build Tools version that will be used as the compile project
PROP_BUILD_TOOLS_VERSION=28.0.2
# List of CPU Archtexture to build that application with
# Available architextures (armeabi-v7a | arm64-v8a | x86)
# To build for multiple architexture, use the `:` between them
# Example - PROP_APP_ABI=armeabi-v7a
PROP_APP_ABI=armeabi-v7a
# fill in sign information for release mode
RELEASE_STORE_FILE=/Applications/CocosCreator/Creator/3.1.1/CocosCreator.app/Contents/Resources/tools/keystore/debug.keystore
RELEASE_STORE_PASSWORD=123456
RELEASE_KEY_ALIAS=debug_keystore
RELEASE_KEY_PASSWORD=123456

View File

@@ -0,0 +1,6 @@
#Fri Oct 27 10:18:28 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip

164
cx3-demo/project/cxdemo.android/gradlew vendored Executable file
View File

@@ -0,0 +1,164 @@
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

90
cx3-demo/project/cxdemo.android/gradlew.bat vendored Executable file
View File

@@ -0,0 +1,90 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@@ -0,0 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.cocos.lib">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
</manifest>

View File

@@ -0,0 +1,34 @@
apply plugin: 'com.android.library'
android {
compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger()
defaultConfig {
minSdkVersion PROP_MIN_SDK_VERSION
targetSdkVersion PROP_TARGET_SDK_VERSION
versionCode 1
versionName "1.0"
}
sourceSets.main {
java.srcDir "../../../../cx-framework3.1/cocos3-libs/cocos3-libcc/src"
res.srcDirs "../../../../cx-framework3.1/cocos3-libs/cocos3-libcc/res"
jniLibs.srcDirs = ["../../../../cx-framework3.1/cocos3-libs/cocos3-libcc/libs"]
manifest.srcFile "AndroidManifest.xml"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: '../../../../cx-framework3.1/cocos3-libs/cocos3-libcc/libs')
}

View File

@@ -0,0 +1,10 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in E:\developSoftware\Android\SDK/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:

View File

@@ -0,0 +1,9 @@
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Sun Aug 02 14:51:16 CST 2020
ndk.dir=/Users/blank/Library/Android/sdk/ndk-bundle
sdk.dir=/Users/blank/Library/Android/sdk

View File

@@ -0,0 +1,2 @@
include ':app'
include ':libcc'