Skip to content

Commit afd65d0

Browse files
author
liuchuancong
committed
fix(修复重连)
1 parent a352383 commit afd65d0

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

lib/player/media_kit_adapter.dart

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,19 @@ class MediaKitPlayerAdapter implements UnifiedPlayer {
5252
await pp.setProperty('force-seekable', 'yes');
5353
}
5454
if (_player.platform is NativePlayer) {
55-
await (_player.platform as dynamic).setProperty(
56-
'protocol_whitelist',
57-
'httpproxy,udp,rtp,tcp,tls,data,file,http,https,crypto',
58-
);
55+
if (_player.platform is NativePlayer) {
56+
final native = _player.platform as dynamic;
57+
58+
// 1. 设置协议白名单
59+
await native.setProperty('protocol_whitelist', 'httpproxy,udp,rtp,tcp,tls,data,file,http,https,crypto');
60+
61+
// 2. 合并设置 demuxer 参数 (用逗号分隔,不要分两次 set)
62+
// 这样同时开启了重连和 5 秒超时
63+
await native.setProperty('demuxer-lavf-o', 'reconnect=1,timeout=5000000');
64+
65+
// 3. 设置流重连参数
66+
await native.setProperty('stream-lavf-o', 'reconnect_streamed=1,reconnect_delay_max=5');
67+
}
5968
}
6069

6170
// Initialize controller based on settings

0 commit comments

Comments
 (0)