提交 5f170bba authored 作者: kongdywang's avatar kongdywang

fix bug

上级 36f702fd
......@@ -2,6 +2,7 @@
package com.tencent.vod.flutter;
import android.app.Activity;
import android.app.AppOpsManager;
import android.app.PendingIntent;
import android.app.PictureInPictureParams;
import android.app.RemoteAction;
......@@ -110,7 +111,10 @@ public class FTXPIPManager {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
params.mPipParams = new PictureInPictureParams.Builder();
updatePipActions(isPlaying, params);
mActivity.enterPictureInPictureMode(params.mPipParams.build());
boolean enterResult = mActivity.enterPictureInPictureMode(params.mPipParams.build());
if(!enterResult) {
pipResult = FTXEvent.ERROR_PIP_DENIED_PERMISSION;
}
} else {
mActivity.enterPictureInPictureMode();
}
......@@ -129,6 +133,9 @@ public class FTXPIPManager {
if (!isSuccess) {
pipResult = FTXEvent.ERROR_PIP_DENIED_PERMISSION;
Log.e(TAG, "enterPip failed,because PIP feature is disabled");
} else if(!hasPipPermission()) {
pipResult = FTXEvent.ERROR_PIP_DENIED_PERMISSION;
Log.e(TAG, "enterPip failed,because PIP has no permission");
}
} else {
pipResult = FTXEvent.ERROR_PIP_LOWER_VERSION;
......@@ -142,6 +149,17 @@ public class FTXPIPManager {
return pipResult;
}
private boolean hasPipPermission() {
AppOpsManager appOpsManager = (AppOpsManager) mActivity.getSystemService(Context.APP_OPS_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
int permissionResult = appOpsManager.checkOpNoThrow(AppOpsManager.OPSTR_PICTURE_IN_PICTURE,
android.os.Process.myUid(),mActivity.getPackageName());
return permissionResult == AppOpsManager.MODE_ALLOWED;
} else {
return false;
}
}
public boolean isInPipMode() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
return mActivity.isInPictureInPictureMode();
......
......@@ -122,10 +122,11 @@ public class FTXFlutterPipActivity extends FlutterActivity {
@Override
public boolean enterPictureInPictureMode(@NonNull PictureInPictureParams params) {
if (null != mEventSink) {
boolean enterResult = super.enterPictureInPictureMode(params);
if (enterResult && null != mEventSink) {
mEventSink.success(getParams(EVENT_PIP_MODE_REQUEST_START, null));
}
return super.enterPictureInPictureMode(params);
return enterResult;
}
private Map<String, Object> getParams(int event, Bundle bundle) {
......
......@@ -4,7 +4,7 @@
#import "FTXPlayerEventSinkQueue.h"
#import "FTXEvent.h"
#import "FTXDownloadManager.h"
#import "TXVodPreloadManager.h"
#import <TXLiteAVSDK_Player/TXVodPreloadManager.h>
#import <TXLiteAVSDK_Player/TXVodDownloadManager.h>
#import "FTXEvent.h"
#import "CommonUtil.h"
......
......@@ -66,11 +66,20 @@ BOOL volatile isStop = false;
_netStatusChannel = [FlutterEventChannel eventChannelWithName:[@"cloud.tencent.com/txvodplayer/net/" stringByAppendingString:[self.playerId stringValue]] binaryMessenger:[registrar messenger]];
[_netStatusChannel setStreamHandler:self];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onApplicationTerminateClick) name:UIApplicationWillTerminateNotification object:nil];
}
return self;
}
- (void)onApplicationTerminateClick {
[_txVodPlayer removeVideoWidget];
_txVodPlayer = nil;
_txVodPlayer.videoProcessDelegate = nil;
_textureId = -1;
}
- (void)destory
{
[self stopPlay];
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论