|
@@ -3,10 +3,16 @@ package com.izouma.mobilecybergames;
|
|
|
import android.app.Activity;
|
|
import android.app.Activity;
|
|
|
import android.content.Context;
|
|
import android.content.Context;
|
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
|
|
|
+import android.graphics.PixelFormat;
|
|
|
import android.media.projection.MediaProjectionManager;
|
|
import android.media.projection.MediaProjectionManager;
|
|
|
|
|
+import android.net.Uri;
|
|
|
|
|
+import android.os.Build;
|
|
|
|
|
+import android.provider.Settings;
|
|
|
import android.text.TextUtils;
|
|
import android.text.TextUtils;
|
|
|
import android.util.Log;
|
|
import android.util.Log;
|
|
|
|
|
+import android.view.Gravity;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
|
|
+import android.view.WindowManager;
|
|
|
import android.widget.Toast;
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
import com.alivc.live.pusher.AlivcAudioAACProfileEnum;
|
|
import com.alivc.live.pusher.AlivcAudioAACProfileEnum;
|
|
@@ -26,6 +32,8 @@ import io.flutter.plugin.common.MethodCall;
|
|
|
import io.flutter.plugin.common.MethodChannel;
|
|
import io.flutter.plugin.common.MethodChannel;
|
|
|
import io.flutter.plugin.common.PluginRegistry;
|
|
import io.flutter.plugin.common.PluginRegistry;
|
|
|
|
|
|
|
|
|
|
+import static android.content.Context.WINDOW_SERVICE;
|
|
|
|
|
+
|
|
|
public class ScreenStreamPlugin implements MethodChannel.MethodCallHandler, PluginRegistry.ActivityResultListener {
|
|
public class ScreenStreamPlugin implements MethodChannel.MethodCallHandler, PluginRegistry.ActivityResultListener {
|
|
|
private static final String TAG = "ScreenStreamPlugin";
|
|
private static final String TAG = "ScreenStreamPlugin";
|
|
|
public static final int CAPTURE_PERMISSION_REQUEST_CODE = 0x1123;
|
|
public static final int CAPTURE_PERMISSION_REQUEST_CODE = 0x1123;
|
|
@@ -77,7 +85,7 @@ public class ScreenStreamPlugin implements MethodChannel.MethodCallHandler, Plug
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public boolean start() {
|
|
|
|
|
|
|
+ private boolean start() {
|
|
|
if (started) {
|
|
if (started) {
|
|
|
mAlivcLivePusher.stopPush();
|
|
mAlivcLivePusher.stopPush();
|
|
|
return true;
|
|
return true;
|
|
@@ -91,14 +99,32 @@ public class ScreenStreamPlugin implements MethodChannel.MethodCallHandler, Plug
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public boolean stop() {
|
|
|
|
|
|
|
+ private void checkPermission() {
|
|
|
|
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {//判断系统版本
|
|
|
|
|
+ if (!Settings.canDrawOverlays(registrar.context())) {
|
|
|
|
|
+ Toast.makeText(registrar.activity(), "当前无权限,请授权", Toast.LENGTH_SHORT).show();
|
|
|
|
|
+ registrar.activity().startActivityForResult(new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + registrar.context().getPackageName())), 0);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ showFloatWindow();
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ showFloatWindow();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void showFloatWindow() {
|
|
|
|
|
+ Intent intent = new Intent(registrar.context(), ScreenStreamService.class);
|
|
|
|
|
+ registrar.context().startService(intent);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private boolean stop() {
|
|
|
if (mAlivcLivePusher != null && mAlivcLivePusher.isPushing()) {
|
|
if (mAlivcLivePusher != null && mAlivcLivePusher.isPushing()) {
|
|
|
mAlivcLivePusher.stopPush();
|
|
mAlivcLivePusher.stopPush();
|
|
|
}
|
|
}
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void startPushWithoutSurface() {
|
|
|
|
|
|
|
+ private void startPushWithoutSurface() {
|
|
|
mAlivcLivePusher = new AlivcLivePusher();
|
|
mAlivcLivePusher = new AlivcLivePusher();
|
|
|
try {
|
|
try {
|
|
|
mAlivcLivePusher.init(registrar.context(), mAlivcLivePushConfig);
|
|
mAlivcLivePusher.init(registrar.context(), mAlivcLivePushConfig);
|