Skip to content

Commit 8ea0a67

Browse files
author
kongdywang
committed
1. Added Picture-in-Picture capability for iOS live streaming.
2. Fixed the Picture-in-Picture service leak issue on Android.
1 parent b4fe752 commit 8ea0a67

31 files changed

+1513
-145
lines changed

Flutter/android/src/main/java/com/tencent/vod/flutter/FTXLivePlayer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.graphics.SurfaceTexture;
77
import android.os.Bundle;
88
import android.view.Surface;
9+
import android.view.TextureView;
910

1011
import androidx.annotation.NonNull;
1112

@@ -65,7 +66,7 @@ public class FTXLivePlayer extends FTXBasePlayer implements TXFlutterLivePlayerA
6566
private final FTXV2LiveObserver mObserver;
6667
private int mLastPlayEvent = -1;
6768
private boolean mIsPaused = false;
68-
private FtxMessages.TXLivePlayerFlutterAPI mLiveFlutterApi;
69+
private final FtxMessages.TXLivePlayerFlutterAPI mLiveFlutterApi;
6970

7071
private final FTXPIPManager.PipCallback pipCallback = new FTXPIPManager.PipCallback() {
7172
@Override

Flutter/android/src/main/java/com/tencent/vod/flutter/SuperPlayerPlugin.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ public PlayerMsg createVodPlayer() {
204204
mPlayers.append(playerId, player);
205205
PlayerMsg playerMsg = new PlayerMsg();
206206
playerMsg.setPlayerId((long) playerId);
207+
LiteavLog.i(TAG, "createVodPlayer :" + playerId);
207208
return playerMsg;
208209
}
209210

@@ -215,6 +216,7 @@ public PlayerMsg createLivePlayer() {
215216
mPlayers.append(playerId, player);
216217
PlayerMsg playerMsg = new PlayerMsg();
217218
playerMsg.setPlayerId((long) playerId);
219+
LiteavLog.i(TAG, "createLivePlayer :" + playerId);
218220
return playerMsg;
219221
}
220222

@@ -229,8 +231,10 @@ public void setConsoleEnabled(@NonNull BoolMsg enabled) {
229231
public void releasePlayer(@NonNull PlayerMsg playerId) {
230232
if (null != playerId.getPlayerId()) {
231233
int intPlayerId = playerId.getPlayerId().intValue();
234+
LiteavLog.i(TAG, "releasePlayer :" + intPlayerId);
232235
FTXBasePlayer player = mPlayers.get(intPlayerId);
233236
if (player != null) {
237+
LiteavLog.i(TAG, "releasePlayer start destroy player :" + intPlayerId);
234238
player.destroy();
235239
mPlayers.remove(intPlayerId);
236240
}

Flutter/android/src/main/java/com/tencent/vod/flutter/ui/FlutterPipImplActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ protected void onDestroy() {
498498

499499
private void bindAndroid12BugServiceIfNeed() {
500500
if (Build.VERSION.SDK_INT >= VERSION_CODES.Q) {
501-
Intent serviceIntent = new Intent(this, TXAndroid12BridgeService.class);
501+
Intent serviceIntent = new Intent(getApplicationContext(), TXAndroid12BridgeService.class);
502502
startService(serviceIntent);
503503
bindService(serviceIntent, this, Context.BIND_AUTO_CREATE);
504504
}

Flutter/ios/Classes/FTXEvent.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@
4545
/// PIP function is not started.
4646
/// PIP功能没有启动
4747
#define ERROR_IOS_PIP_NOT_RUNNING -111
48+
/// PIP start time out
49+
/// PIP 启动超时
50+
#define ERROR_IOS_PIP_START_TIME_OUT -112
51+
/// Insufficient permissions, currently only appears in Picture-in-Picture live streaming
52+
/// 权限不足,目前只出现在直播画中画
53+
#define ERROR_PIP_AUTH_DENIED -201
4854

4955

5056

Flutter/ios/Classes/FTXLivePlayer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44

55
#import <Foundation/Foundation.h>
66
#import "FTXBasePlayer.h"
7+
#import "FTXVodPlayerDelegate.h"
78

89
@protocol FlutterPluginRegistrar;
910

1011
NS_ASSUME_NONNULL_BEGIN
1112

1213
@interface FTXLivePlayer : FTXBasePlayer
1314

15+
@property(nonatomic, weak) id<FTXVodPlayerDelegate> delegate;
16+
1417
- (instancetype)initWithRegistrar:(id<FlutterPluginRegistrar>)registrar;
1518

1619
- (void)notifyAppTerminate:(UIApplication *)application;

0 commit comments

Comments
 (0)