提交 9c50b0ab authored 作者: kongdywang's avatar kongdywang

fix app occasionally crash when kill app and player destroy

上级 ad494d51
......@@ -210,7 +210,7 @@ public class FTXVodPlayer extends FTXBasePlayer implements ITXVodPlayListener, F
// software decoding will depend on the window rendering of the surface. Failure to update will result
// in only 1 pixel of content.
private void setDefaultBufferSizeForSoftDecode(int width, int height) {
if (mSurfaceTextureEntry != null) {
if (null != mVodPlayer && mSurfaceTextureEntry != null) {
SurfaceTexture surfaceTexture = mSurfaceTextureEntry.surfaceTexture();
surfaceTexture.setDefaultBufferSize(width, height);
mSurface = new Surface(surfaceTexture);
......
......@@ -372,7 +372,7 @@ public class SuperPlayerPlugin implements FlutterPlugin, ActivityAware,
@Override
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
Log.i(TAG, "onAttachedToEngine");
Log.i(TAG, "onDetachedFromEngine");
mFTXDownloadManager.destroy();
mFlutterPluginBinding = null;
if (null != mOrientationManager) {
......
......@@ -249,6 +249,7 @@
};
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
......@@ -263,6 +264,7 @@
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
......
......@@ -39,7 +39,7 @@ class _DemoTXVodPlayerState extends State<DemoTXVodPlayer> with WidgetsBindingOb
Future<void> init() async {
if (!mounted) return;
await SuperPlayerPlugin.setConsoleEnabled(true);
_controller = TXVodPlayerController();
await _controller.initialize();
_controller.onPlayerState.listen((val) {
debugPrint("Playback status ${val?.name}");
});
......@@ -81,8 +81,6 @@ class _DemoTXVodPlayerState extends State<DemoTXVodPlayer> with WidgetsBindingOb
});
}
});
await _controller.initialize();
await _controller.setLoop(true);
await _controller.enableHardwareDecode(enableHardware);
await _controller.setAudioPlayoutVolume(volume);
......@@ -91,16 +89,6 @@ class _DemoTXVodPlayerState extends State<DemoTXVodPlayer> with WidgetsBindingOb
await _controller.startVodPlay(_url);
}
void startPlay() async {
await _controller.startVodPlayWithParams(TXPlayInfoParams(appId: 1500005830, fileId: "243791578431393746",
psign: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6MTUwMDAwNTgzMCwiZmlsZUlkIjoiMjQzNzkxNTc4NDMxMzkzNzQ2IiwiY"
"3VycmVudFRpbWVTdGFtcCI6MTY3MzQyNjIyNywiY29udGVudEluZm8iOnsiYXVkaW9WaWRlb1R5cGUiOiJQcm90ZWN0ZWRBZGFwdGl"
"2ZSIsImRybUFkYXB0aXZlSW5mbyI6eyJwcml2YXRlRW5jcnlwdGlvbkRlZmluaXRpb24iOjEyfX0sInVybEFjY2Vzc0luZm8iOnsiZ"
"G9tYWluIjoiMTUwMDAwNTgzMC52b2QyLm15cWNsb3VkLmNvbSIsInNjaGVtZSI6IkhUVFBTIn19.q34pq7Bl0ryKDwUHGyzfXKP-C"
"DI8vrm0k_y-IaxgF_U"));
}
void _resizeVideo(Map<dynamic, dynamic> event) {
int? videoWidth = event[TXVodPlayEvent.EVT_PARAM1];
int? videoHeight = event[TXVodPlayEvent.EVT_PARAM2];
......@@ -114,6 +102,7 @@ class _DemoTXVodPlayerState extends State<DemoTXVodPlayer> with WidgetsBindingOb
@override
void initState() {
super.initState();
_controller = TXVodPlayerController();
init();
WidgetsBinding.instance.addObserver(this);
EasyLoading.show(status: 'loading...');
......
......@@ -481,7 +481,7 @@ static const int CODE_ON_RECEIVE_FIRST_FRAME = 2003;
if (old && old != pixelBuffer) {
CFRelease(old);
}
if (_textureId >= 0 && _textureRegistry) {
if (_textureRegistry && _textureId && _textureId >= 0) {
[_textureRegistry textureFrameAvailable:_textureId];
}
}
......
......@@ -168,13 +168,13 @@ class SuperPlayerController {
_updatePlayerState(SuperPlayerState.END);
break;
case TXVodPlayEvent.PLAY_EVT_PLAY_PROGRESS:
dynamic progress = event[TXVodPlayEvent.EVT_PLAY_PROGRESS];
dynamic duration = event[TXVodPlayEvent.EVT_PLAY_DURATION];
dynamic progress = event[TXVodPlayEvent.EVT_PLAY_PROGRESS_MS];
dynamic duration = event[TXVodPlayEvent.EVT_PLAY_DURATION_MS];
if (null != progress) {
currentDuration = progress.toDouble(); // Current time, converted unit: seconds
currentDuration = progress.toDouble()/1000; // Current time, converted unit: seconds
}
if (null != duration) {
videoDuration = duration.toDouble(); // Total playback time, converted unit: seconds
videoDuration = duration.toDouble()/1000; // Total playback time, converted unit: seconds
}
if (videoDuration != 0) {
_observer?.onPlayProgress(currentDuration, videoDuration, await getPlayableDuration());
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论