提交 56a44e10 authored 作者: kongdywang's avatar kongdywang

1. Avoid occasional crashes when iOS kills processes

2. Fix occasional wild pointer access issues with callback messages during iOS startup 3. Remove pigeon dependency to avoid conflicts with customer versions 4. Fix compatibility issues with Picture-in-Picture broadcast events when the target is Android 14 5. Fix null pointer judgment in iOS player release 6. Fix logic for getting the current ViewController in Picture-in-Picture on the iOS side
上级 c82b27d5
......@@ -420,7 +420,9 @@ public class FTXPIPManager implements TXSimpleEventBus.EventSubscriber {
Bundle backData = new Bundle();
backData.putInt(FTXEvent.EXTRA_NAME_PLAY_OP, FTXEvent.EXTRA_PIP_PLAY_BACK);
backData.putInt(FTXEvent.EXTRA_NAME_PLAYER_ID, mCurrentPlayerId);
Intent backIntent = new Intent(FTXEvent.ACTION_PIP_PLAY_CONTROL).putExtras(backData);
Intent backIntent = new Intent(FTXEvent.ACTION_PIP_PLAY_CONTROL)
.putExtras(backData)
.setPackage(activity.getPackageName());
PendingIntent preIntent = PendingIntent.getBroadcast(activity, FTXEvent.EXTRA_PIP_PLAY_BACK, backIntent,
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);
RemoteAction preAction = new RemoteAction(getBackIcon(activity), "skipPre", "skip pre", preIntent);
......@@ -432,8 +434,9 @@ public class FTXPIPManager implements TXSimpleEventBus.EventSubscriber {
Bundle playOrPauseData = new Bundle();
playOrPauseData.putInt(FTXEvent.EXTRA_NAME_PLAYER_ID, mCurrentPlayerId);
playOrPauseData.putInt(FTXEvent.EXTRA_NAME_PLAY_OP, FTXEvent.EXTRA_PIP_PLAY_RESUME_OR_PAUSE);
Intent playOrPauseIntent =
new Intent(FTXEvent.ACTION_PIP_PLAY_CONTROL).putExtras(playOrPauseData);
Intent playOrPauseIntent = new Intent(FTXEvent.ACTION_PIP_PLAY_CONTROL)
.putExtras(playOrPauseData)
.setPackage(activity.getPackageName());
Icon playIcon = mIsPlaying ? getPauseIcon(activity) : getPlayIcon(activity);
PendingIntent playIntent = PendingIntent.getBroadcast(activity, a.incrementAndGet(),
playOrPauseIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);
......@@ -446,7 +449,9 @@ public class FTXPIPManager implements TXSimpleEventBus.EventSubscriber {
Bundle forwardData = new Bundle();
forwardData.putInt(FTXEvent.EXTRA_NAME_PLAY_OP, FTXEvent.EXTRA_PIP_PLAY_FORWARD);
forwardData.putInt(FTXEvent.EXTRA_NAME_PLAYER_ID, mCurrentPlayerId);
Intent forwardIntent = new Intent(FTXEvent.ACTION_PIP_PLAY_CONTROL).putExtras(forwardData);
Intent forwardIntent = new Intent(FTXEvent.ACTION_PIP_PLAY_CONTROL)
.putExtras(forwardData)
.setPackage(activity.getPackageName());
PendingIntent nextIntent = PendingIntent.getBroadcast(activity, FTXEvent.EXTRA_PIP_PLAY_FORWARD,
forwardIntent,
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);
......
......@@ -32,7 +32,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.tencent.liteav.demo"
minSdkVersion 19
targetSdk 33
targetSdk 34
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
......
......@@ -61,7 +61,7 @@
}
- (void)onStartEvent:(long)tmpTaskId taskID:(int)taskID fileId:(NSString *)fileId url:(NSString *)url param:(NSDictionary *)param {
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
__block NSMutableDictionary *dict = [NSMutableDictionary dictionary];
[dict setObject:@(tmpTaskId) forKey:@"tmpTaskId"];
[dict setObject:@(taskID) forKey:@"taskId"];
[dict setObject:fileId forKey:@"fileId"];
......@@ -71,7 +71,7 @@
}
- (void)onErrorEvent:(long)tmpTaskId taskId:(int)taskID url:(NSString *)url error:(NSError *)error {
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
__block NSMutableDictionary *dict = [NSMutableDictionary dictionary];
if (tmpTaskId >= 0) {
[dict setObject:@(tmpTaskId) forKey:@"tmpTaskId"];
}
......@@ -124,7 +124,7 @@
+ (NSDictionary *)getParamsWithEvent:(int)EvtID withParams:(NSDictionary *)params
{
NSMutableDictionary<NSString*,NSObject*> *dict = [NSMutableDictionary dictionaryWithObject:@(EvtID) forKey:@"event"];
__block NSMutableDictionary<NSString*,NSObject*> *dict = [NSMutableDictionary dictionaryWithObject:@(EvtID) forKey:@"event"];
if (params != nil && params.count != 0) {
[dict addEntriesFromDictionary:params];
}
......@@ -135,7 +135,7 @@
- (void)onComplete:(int)taskID url:(NSString *)url
{
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
__block NSMutableDictionary *dict = [NSMutableDictionary dictionary];
[dict setObject:@(taskID) forKey:@"taskId"];
[dict setObject:url forKey:@"url"];
[_eventSink success:[FTXDownloadManager getParamsWithEvent:EVENT_PREDOWNLOAD_ON_COMPLETE withParams:dict]];
......@@ -177,7 +177,7 @@
}
- (NSMutableDictionary *)buildMapFromDownloadMediaInfo:(TXVodDownloadMediaInfo *)info{
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
__block NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
if(nil != info) {
[dict setValue:info.playPath forKey:@"playPath"];
[dict setValue:@(info.progress) forKey:@"progress"];
......
......@@ -117,15 +117,15 @@ static const int uninitialized = -1;
- (void)notifyPlayerTerminate {
FTXLOGW(@"livePlayer notifyPlayerTerminate");
_isTerminate = YES;
_textureRegistry = nil;
[self stopPlay];
if (nil != _txLivePlayer) {
[_txLivePlayer removeVideoWidget];
_txLivePlayer.videoProcessDelegate = nil;
_txLivePlayer = nil;
[_txLivePlayer removeVideoWidget];
}
_isTerminate = YES;
_textureRegistry = nil;
[self stopPlay];
_textureId = -1;
_txLivePlayer = nil;
}
- (void)setupPlayerWithBool:(BOOL)onlyAudio
......
......@@ -112,15 +112,15 @@ static const int CODE_ON_RECEIVE_FIRST_FRAME = 2003;
- (void)notifyPlayerTerminate {
FTXLOGW(@"vodPlayer notifyPlayerTerminate");
_isTerminate = YES;
_textureRegistry = nil;
[self stopPlay];
if (nil != _txVodPlayer) {
[_txVodPlayer removeVideoWidget];
_txVodPlayer.videoProcessDelegate = nil;
_txVodPlayer = nil;
[_txVodPlayer removeVideoWidget];
}
_isTerminate = YES;
_textureRegistry = nil;
[self stopPlay];
_textureId = -1;
_txVodPlayer = nil;
}
- (void)destory
......@@ -715,7 +715,7 @@ static const int CODE_ON_RECEIVE_FIRST_FRAME = 2003;
[self.delegate onPlayerPipRequestStart];
}
UIViewController* flutterVC = [[[UIApplication sharedApplication] keyWindow] rootViewController];
UIViewController* flutterVC = [self getFlutterViewController];
[flutterVC.view addSubview:self.txPipView];
[_txVodPlayer setupVideoWidget:self.txPipView insertIndex:0];
[_txVodPlayer enterPictureInPicture];
......@@ -732,6 +732,35 @@ static const int CODE_ON_RECEIVE_FIRST_FRAME = 2003;
return _txPipView;
}
- (UIViewController *)getFlutterViewController {
UIWindow *window = nil;
if (@available(iOS 13.0, *)) {
NSSet<UIScene *> *connectedScenes = [UIApplication sharedApplication].connectedScenes;
for (UIScene *scene in connectedScenes) {
if ([scene isKindOfClass:[UIWindowScene class]]) {
UIWindowScene *windowScene = (UIWindowScene *)scene;
for (UIWindow *w in windowScene.windows) {
if (w.isKeyWindow) {
window = w;
break;
}
}
if (window != nil) {
break;
}
}
}
} else {
for (UIWindow *w in [UIApplication sharedApplication].windows) {
if (w.isKeyWindow) {
window = w;
break;
}
}
}
return window.rootViewController;
}
#pragma mark - PIP delegate
- (void)onPlayer:(TXVodPlayer *)player pictureInPictureStateDidChange:(TX_VOD_PLAYER_PIP_STATE)pipState withParam:(NSDictionary *)param {
if (pipState == TX_VOD_PLAYER_PIP_STATE_DID_START) {
......
......@@ -129,8 +129,8 @@ SuperPlayerPlugin* instance;
-(void) releasePlayerInner:(NSNumber*)playerId {
FTXLOGV(@"called releasePlayerInner,%@ is start release", playerId);
FTXBasePlayer *player = [_players objectForKey:playerId];
[player destory];
if (player != nil) {
[player destory];
[_players removeObjectForKey:playerId];
}
}
......@@ -424,10 +424,13 @@ SuperPlayerPlugin* instance;
- (void)onLicenceLoaded:(int)result Reason:(NSString *)reason {
FTXLOGV(@"onLicenceLoaded,result:%d, reason:%@", result, reason);
[_eventSink success:[SuperPlayerPlugin getParamsWithEvent:EVENT_ON_LICENCE_LOADED withParams:@{
@(EVENT_RESULT) : @(result),
@(EVENT_REASON) : reason,
}]];
__block int blockResult = result;
__block NSString* blockReason = reason;
__block NSDictionary *param = @{
@(EVENT_RESULT) : @(blockResult),
@(EVENT_REASON) : blockReason,
};
[_eventSink success:[SuperPlayerPlugin getParamsWithEvent:EVENT_ON_LICENCE_LOADED withParams:param]];
}
......
......@@ -11,7 +11,7 @@ environment:
dependencies:
flutter:
sdk: flutter
pigeon: ^9.0.1
# pigeon: ^9.0.1
synchronized: ^3.0.0+3
# internationalization
flutter_localizations:
......@@ -19,7 +19,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
pigeon: ^9.0.1
# pigeon: ^9.0.1
synchronized: ^3.0.0+3
# For information on the generic Dart part of this file, see the
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论