You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
vlc_flutter_player 7.4.4 throws PlatformException (PlatformException(channel-error, Unable to establish connection on channel., null, null)) on android #546
changed the title [-]vlc_flutter_player 7.4.4 throws PlatformException (PlatformException(channel-error, Unable to establish connection on channel., null, null))[/-][+]vlc_flutter_player 7.4.4 throws PlatformException (PlatformException(channel-error, Unable to establish connection on channel., null, null)) on android[/+]on Sep 25, 2025
try {
final options = _buildOptionsForStrategy(strategy, referer, origin);
_controller = VlcPlayerController.network(
url,
hwAcc: _getHwAccForStrategy(strategy),
autoPlay: autoPlay,
options: options,
);
// Surveillance pour Android TV
if (_isAndroidTV) {
_setupAndroidTVHealthMonitoring();
}
return _controller!;
} catch (e) {
logger.e('Échec VLC avec stratégie $strategy: $e');
rethrow;
}
}
/// Surveillance proactive de la santé du stream
void _setupAndroidTVHealthMonitoring() {
// Check toutes les 5 secondes (moins agressif)
_healthCheckTimer = Timer.periodic(const Duration(seconds: 5), (timer) {
_checkStreamHealth();
});
// Surveillance des erreurs
_controller?.addListener(() {
final state = _controller?.value;
if (state?.hasError == true) {
logger.w('Erreur VLC détectée: ${state?.errorDescription}');
_handleStreamError();
}
});
}
/// Vérification de la santé du stream
void _checkStreamHealth() {
final state = _controller?.value;
if (state == null || !state.isInitialized) return;
// Si le stream est en buffering trop longtemps
if (state.isBuffering) {
_bufferHealthChecks++;
logger.d('Stream en buffering... (${_bufferHealthChecks}/5)');
if (_bufferHealthChecks >= 5) {
logger.w('Stream bloqué en buffering, tentative de récupération');
_handleStreamError();
}
} else {
_bufferHealthChecks = 0; // Reset si ça marche
}
// Reset reconnect attempts if playing well
if (state.isPlaying && !state.isBuffering) {
_reconnectAttempts = 0;
}
}
/// Gestion intelligente des erreurs
Future _handleStreamError() async {
if (_reconnectAttempts >= _maxReconnectAttempts) {
logger.e('Trop de tentatives de reconnexion, abandon');
return;
}
_reconnectAttempts++;
_bufferHealthChecks = 0;
logger.i('Récupération automatique $_reconnectAttempts/$_maxReconnectAttempts');
try {
await _hardRestart();
} catch (e) {
logger.e('Erreur lors de la récupération: $e');
}
}
/// Redémarrage complet (plus sûr)
Future _hardRestart() async {
if (_lastUrl == null) return;
logger.i('Recréation complète du player...');
try {
await _safeDispose();
await Future.delayed(const Duration(milliseconds: 1000)); // Plus long pour stabilité
final options = _buildOptionsForStrategy(
PlayerStrategy.androidTVStable,
_lastReferer,
_lastOrigin
);
_controller = VlcPlayerController.network(
_lastUrl!,
hwAcc: HwAcc.auto,
autoPlay: true,
options: options,
);
if (_isAndroidTV) {
_setupAndroidTVHealthMonitoring();
}
} catch (e) {
logger.e('Hard restart échoué: $e');
}
}
/// Hardware acceleration conservateur
HwAcc _getHwAccForStrategy(PlayerStrategy strategy) {
switch (strategy) {
case PlayerStrategy.androidTVStable:
if(performance == 0) { // Eco
logger.d("Eco");
return HwAcc.disabled;
} else if (performance == 1) { // Standard
logger.d("Standard");
return HwAcc.auto;
} else if (performance == 2) { // Optimisé
logger.d("Optimisé");
return HwAcc.full;
}
return HwAcc.disabled; // Auto avec fallback
case PlayerStrategy.iosBalanced:
return HwAcc.full;
}
}
/// Options par stratégie
VlcPlayerOptions _buildOptionsForStrategy(
PlayerStrategy strategy,
String? referer,
String? origin,
) {
switch (strategy) {
case PlayerStrategy.androidTVStable:
return _buildAndroidTVStableOptions(referer, origin);
case PlayerStrategy.iosBalanced:
return _buildIOSFastOptions(referer, origin);
}
}
/// Configuration Android TV stable (options validées)
VlcPlayerOptions _buildAndroidTVStableOptions(String? referer, String? origin) {
final extras = [
'--file-caching=3000',
'--network-caching=3000',
'--live-caching=3000',
'--no-video-title-show',
'--intf=dummy',
'--http-reconnect',
'--http-user-agent=${getUserAgent()}',
// 🔑 Essentiel : forcer un décodage plus “souple”
'--avcodec-skiploopfilter=0',
'--avcodec-skip-frame=0',
'--avcodec-hw=any',
// Permet d’éviter le freeze vidéo
'--drop-late-frames',
'--skip-frames',
'--no-sout-video',
'--adaptive-use-access',
'--adaptive-logic=rate',
// '--verbose=2', // temporairement pour debug
];
if (referer != null && referer.isNotEmpty) {
extras.add('--http-referrer=$referer');
}
if (origin != null && origin.isNotEmpty) {
extras.add('--http-origin=$origin');
}
After locking the screen and leaving it idle for a while, calling initialize on vlc_player_controller again will result in PlatformException(channel-error, Unable to establish connection on channel: "dev.flutter.pigeon.flutter_vlc_player_platform_interface.VlcPlayerApi.create"., null, null)
After locking the screen and leaving it idle for a while, calling initialize on vlc_player_controller again will result in PlatformException(channel-error, Unable to establish connection on channel: "dev.flutter.pigeon.flutter_vlc_player_platform_interface.VlcPlayerApi.create"., null, null)
You can't remove the flutterInjector initialization because FlutterVlcPlayerFactory depends on data provided by that object. specifically injector.flutterLoader()::getLookupKeyForAsset
Hi, running on the same issue as everyone.
Playing videos work in a test environment but implementing vlc player in Piwigo/piwigo-flutter-app#228 doesn't.
This result in infinite loading and [ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: PlatformException(channel-error, Unable to establish connection on channel., null, null) while trying flutter vlc 16kb will outright crash the app with E/VLC ( 9987): [0000006e60bfb440/27b0] http generic: local stream 1 error: Stream closed (0x5)
Hi @nechtas and all. We are busy with other tasks unfortunately, so we can't get on this one right now. But I'm happy to merge any PRs that fix this issue.
check your yamal file , dev dependency is correctly set for testing packages only , if not remove it and add in dependencies section and check after clean ..for new flutter versions, fix my all packages to compile correctly, but not for video working , i still have issue in video playing , this is for missing package Error ....
Activity
[-]vlc_flutter_player 7.4.4 throws PlatformException (PlatformException(channel-error, Unable to establish connection on channel., null, null))[/-][+]vlc_flutter_player 7.4.4 throws PlatformException (PlatformException(channel-error, Unable to establish connection on channel., null, null)) on android[/+]FlawLessx commentedon Sep 25, 2025
did you find solution?
alohadance98 commentedon Sep 25, 2025
I am still waiting for oganize response and hotfix version. I just know after update version of libvlc-all the PlatformException appears
twix44 commentedon Sep 25, 2025
this issue after the latest library update
Flutter 3.35.3
Platform: Android
flutter_vlc_player : 7.4.4
Error message:
P/Quality ( 2103): 07 02 block_gc block_gc otv. player 2103 10510984 1535 I/otv. playe( 2103): WaitForGcToComplete blocked ProfileSaver on HeapTrim for 531.164ms W/Looper ( 2103): Slow delivery took 3386ms main h=android.os.Handler c=io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0@28db91b m=0 W/Looper ( 2103): Drained E/flutter ( 2103): [ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: PlatformException(channel-error, Unable to establish connection on channel., null, null) E/flutter ( 2103): #0 VlcPlayerApi.initialize (package:flutter_vlc_player_platform_interface/src/messages/messages.dart:632:7) E/flutter ( 2103): <asynchronous suspension> E/flutter ( 2103): I/PlatformViewsController( 2103): Hosting view in view hierarchy for platform view: 0 I/PlatformViewsController( 2103): PlatformView is using SurfaceProducer backend D/otv. playe( 2103): DDpid=2103 tid=2160 name=com. . player W/Gralloc4( 2103): allocator 3.x is not supported W/Gralloc3( 2103): allocator 3.x is not supported E/FrameEvents( 2103): updateAcquireFence: Did not find frame. D/otv. playe( 2103): DDpid=2103 tid=2160 name=com. . player E/FrameEvents( 2103): updateAcquireFence: Did not find frame. E/flutter ( 2103): [ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: PlatformException(channel-error, Unable to establish connection on channel., null, null) E/flutter ( 2103): #0 VlcPlayerApi.create (package:flutter_vlc_player_platform_interface/src/messages/messages.dart:658:7) E/flutter ( 2103): <asynchronous suspension> E/flutter ( 2103): #1 VlcPlayerController.initialize (package:flutter_vlc_player/src/vlc_player_controller.dart:191:5) E/flutter ( 2103): <asynchronous suspension> E/flutter ( 2103): #2 VlcPlayerController.onPlatformViewCreated (package:flutter_vlc_player/src/vlc_player_controller.dart:969:7) E/flutter ( 2103): <asynchronous suspension> E/flutter ( 2103): I/otv. playe( 2103): NativeAlloc concurrent copying GC freed 673065(25MB) AllocSpace objects, 0(0B) LOS objects, 49% free, 3076KB/6153KB, paused 134us total 171.812msalohadance98 commentedon Sep 26, 2025
UPDATE: there is a package flutter_vlc_player_16kb on pub.dev which already supports 16kb page size and runs smoothly, you can switch to it @FlawLessx @twix44
FlawLessx commentedon Sep 26, 2025
Thanks for the suggestion @alohadance98 , but now im migrating to media_kit since it use libmpv that reduce app size too
Zeus178 commentedon Sep 29, 2025
I tried flutter_vlc_player_16Kb but still encountered the same error. Do you have a solution yet?
rochelryu commentedon Sep 29, 2025
Anyone have one solution on this bug ?
rochelryu commentedon Sep 29, 2025
this is my error:
PlatformException(channel-error, Unable to establish connection on channel., null, null)
I/flutter ( 9282): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter ( 9282): │ #0 main. (package:stream_ryu/main.dart:106:12)
I/flutter ( 9282): │ #1 _RootZone.runBinary (dart:async/zone.dart:1854:54)
I/flutter ( 9282): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter ( 9282): │ ⛔ Stack trace: #0 VlcPlayerApi.create (package:flutter_vlc_player_platform_interface/src/messages/messages.dart:658:7)
I/flutter ( 9282): │ ⛔
I/flutter ( 9282): │ ⛔ #1 VlcPlayerController.initialize (package:flutter_vlc_player/src/vlc_player_controller.dart:191:5)
I/flutter ( 9282): │ ⛔
I/flutter ( 9282): │ ⛔ #2 VlcPlayerController.onPlatformViewCreated (package:flutter_vlc_player/src/vlc_player_controller.dart:969:7)
I/flutter ( 9282): │ ⛔
I/flutter ( 9282): │ ⛔
I/flutter ( 9282): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
E/FrameEvents( 9282): updateAcquireFence: Did not find frame.
D/EGL_emulation( 9282): app_time_stats: avg=23094.62ms min=23094.62ms max=23094.62ms count=1
this is my code:
import 'package:flutter_vlc_player/flutter_vlc_player.dart';
import 'package:stream_ryu/core/utils/logger.dart';
import '../di/service_locator.dart';
import '../storage/secure_storage_local.dart';
import '../utils/channel_helper.dart';
import 'dart:async';
class VlcPlayerService {
VlcPlayerController? _controller;
bool _isAndroidTV = false;
Timer? _healthCheckTimer;
Timer? _reconnectTimer;
int _bufferHealthChecks = 0;
int _reconnectAttempts = 0;
static const int _maxReconnectAttempts = 3;
String? _lastUrl;
String? _lastReferer;
String? _lastOrigin;
final SecureStorage secureStorage = sl();
int? performance;
VlcPlayerController? get controller => _controller;
/// Détection rapide Android TV
void _initializeDeviceInfo(bool isAndroidTV) {
_isAndroidTV = isAndroidTV;
}
Future loadPerformance() async {
performance = await secureStorage.getPerformance();
}
/// Prépare le player avec stratégies optimisées
Future prepare({
required String url,
required bool isAndroidTV,
String? referer,
String? origin,
bool autoPlay = true,
}) async {
_initializeDeviceInfo(isAndroidTV);
await loadPerformance();
}
Future _prepareWithStrategy(
String url,
String? referer,
String? origin,
bool autoPlay,
PlayerStrategy strategy,
) async {
if (_controller != null) {
await _safeDispose();
}
}
/// Surveillance proactive de la santé du stream
void _setupAndroidTVHealthMonitoring() {
// Check toutes les 5 secondes (moins agressif)
_healthCheckTimer = Timer.periodic(const Duration(seconds: 5), (timer) {
_checkStreamHealth();
});
}
/// Vérification de la santé du stream
void _checkStreamHealth() {
final state = _controller?.value;
if (state == null || !state.isInitialized) return;
}
/// Gestion intelligente des erreurs
Future _handleStreamError() async {
if (_reconnectAttempts >= _maxReconnectAttempts) {
logger.e('Trop de tentatives de reconnexion, abandon');
return;
}
}
/// Redémarrage complet (plus sûr)
Future _hardRestart() async {
if (_lastUrl == null) return;
}
/// Hardware acceleration conservateur
HwAcc _getHwAccForStrategy(PlayerStrategy strategy) {
switch (strategy) {
case PlayerStrategy.androidTVStable:
if(performance == 0) { // Eco
logger.d("Eco");
return HwAcc.disabled;
} else if (performance == 1) { // Standard
logger.d("Standard");
return HwAcc.auto;
} else if (performance == 2) { // Optimisé
logger.d("Optimisé");
return HwAcc.full;
}
return HwAcc.disabled; // Auto avec fallback
case PlayerStrategy.iosBalanced:
return HwAcc.full;
}
}
/// Options par stratégie
VlcPlayerOptions _buildOptionsForStrategy(
PlayerStrategy strategy,
String? referer,
String? origin,
) {
switch (strategy) {
case PlayerStrategy.androidTVStable:
return _buildAndroidTVStableOptions(referer, origin);
case PlayerStrategy.iosBalanced:
return _buildIOSFastOptions(referer, origin);
}
}
/// Configuration Android TV stable (options validées)
VlcPlayerOptions _buildAndroidTVStableOptions(String? referer, String? origin) {
final extras = [
'--file-caching=3000',
'--network-caching=3000',
'--live-caching=3000',
];
if (referer != null && referer.isNotEmpty) {
extras.add('--http-referrer=$referer');
}
if (origin != null && origin.isNotEmpty) {
extras.add('--http-origin=$origin');
}
return VlcPlayerOptions(
advanced: VlcAdvancedOptions([
VlcAdvancedOptions.networkCaching(3000),
]),
video: VlcVideoOptions([
VlcVideoOptions.dropLateFrames(true),
VlcVideoOptions.skipFrames(true),
]),
audio: VlcAudioOptions([
VlcAudioOptions.audioTimeStretch(true),
]),
http: _buildSimpleHttpOptions(referer, origin),
extras: extras,
);
}
/// iOS options inchangées
VlcPlayerOptions _buildIOSFastOptions(String? referer, String? origin) {
final extras = [
'--intf=dummy',
'--no-video-title-show',
}
/// HTTP options simplifiées
VlcHttpOptions _buildSimpleHttpOptions(String? referer, String? origin) {
final options = [
VlcHttpOptions.httpReconnect(true),
];
}
/// Nettoyage des timers
Future _cleanupTimers() async {
_healthCheckTimer?.cancel();
_reconnectTimer?.cancel();
_healthCheckTimer = null;
_reconnectTimer = null;
}
/// Contrôles de base
Future play() async {
try {
await _controller?.play();
_reconnectAttempts = 0;
logger.d('Lecture démarrée');
} catch (e) {
logger.e("Erreur play: $e");
if (_isAndroidTV) {
await _handleStreamError();
}
}
}
Future pause() async {
try {
await _controller?.pause();
logger.d('Lecture mise en pause');
} catch (e) {
logger.e("Erreur pause: $e");
}
}
Future stop() async {
try {
await _cleanupTimers();
await _controller?.stop();
logger.d('Lecture arrêtée');
} catch (e) {
logger.e("Erreur stop: $e");
}
}
Future dispose() async => _safeDispose();
/// Disposal ultra sécurisé
Future _safeDispose() async {
await _cleanupTimers();
}
// Getters de base
bool get isPlaying => _controller?.value.isPlaying ?? false;
bool get isInitialized => _controller?.value.isInitialized ?? false;
bool get hasError => _controller?.value.hasError ?? false;
bool get isBuffering => _controller?.value.isBuffering ?? false;
// Contrôles essentiels
Future seekTo(Duration position) async {
try {
await _controller?.seekTo(position);
} catch (e) {
logger.e("Erreur seek: $e");
}
}
Future setVolume(int volume) async {
try {
await _controller?.setVolume(volume.clamp(0, 100));
} catch (e) {
logger.e("Erreur volume: $e");
}
}
/// Force une récupération manuelle
Future forceRecover() async {
if (_isAndroidTV) {
logger.i("Récupération manuelle forcée");
await _hardRestart();
}
}
/// Statistiques de santé
Map<String, dynamic> get healthStats => {
'reconnectAttempts': _reconnectAttempts,
'bufferHealthChecks': _bufferHealthChecks,
'isHealthy': _reconnectAttempts == 0 && _bufferHealthChecks < 3,
'hasMonitoring': _healthCheckTimer?.isActive ?? false,
};
}
enum PlayerStrategy {
androidTVStable,
iosBalanced,
}
rochelryu commentedon Sep 29, 2025
The problem depend of new version flutter stable.
Zeus178 commentedon Sep 29, 2025
Have you found a solution yet? If so, please share it with me.
alohadance98 commentedon Sep 29, 2025
@rochelryu @Zeus178 there is a package fork from vlc_flutter_player which has been fix the error in my comment above
Zeus178 commentedon Sep 29, 2025
i tried flutter_vlc_player_16kb: ^7.4.7 but still same err
hezhipengzipp commentedon Sep 29, 2025
CristianCruz-Almanza commentedon Sep 29, 2025
Has anyone been able to find a solution to this problem?
rochelryu commentedon Sep 29, 2025
@alohadance98 @Zeus178 @CristianCruz-Almanza , flutter_vlc_player_16kb (https://pub.dev/packages/flutter_vlc_player_16kb) solve this problem but, is not stable on live stream.
@hezhipengzipp Which file should we modify on this picture ?
hezhipengzipp commentedon Sep 30, 2025
jorelkimcruz commentedon Oct 1, 2025
You can't remove the flutterInjector initialization because FlutterVlcPlayerFactory depends on data provided by that object. specifically injector.flutterLoader()::getLookupKeyForAsset
babayanta1994 commentedon Oct 6, 2025
Has anyone managed to solve this terrible problem?
Renarde-dev commentedon Oct 7, 2025
Hi, running on the same issue as everyone.
Playing videos work in a test environment but implementing vlc player in Piwigo/piwigo-flutter-app#228 doesn't.
This result in infinite loading and
[ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: PlatformException(channel-error, Unable to establish connection on channel., null, null)while trying flutter vlc 16kb will outright crash the app withE/VLC ( 9987): [0000006e60bfb440/27b0] http generic: local stream 1 error: Stream closed (0x5)nechtas commentedon Oct 21, 2025
Any updates on this? At the end of this month Play Store force to update all app bundles to 16KB page size but last release is almost not working.
illia-romanenko commentedon Oct 21, 2025
Hi @nechtas and all. We are busy with other tasks unfortunately, so we can't get on this one right now. But I'm happy to merge any PRs that fix this issue.
peter9teufel commentedon Oct 25, 2025
same issue, switching to flutter_vlc_player_16kb fork worked for me, so fixed for now until there's time here to fix it 👍
bmaehr commentedon Jan 4, 2026
@illia-romanenko New year, new roadmap? Do you think you will be able to solve this doring the next weeks?
Lishalkarthikeyan commentedon Feb 17, 2026
check your yamal file , dev dependency is correctly set for testing packages only , if not remove it and add in dependencies section and check after clean ..for new flutter versions, fix my all packages to compile correctly, but not for video working , i still have issue in video playing , this is for missing package Error ....