How to detect incorrect network data source
What is the correct way to detect incorrect network data source which was inputted by a user?
So my current use case:
- user input some network resource in the regular text input
- app provides some basic URL validation
- and if validation passed create
VlcPlayerControllerviaVlcPlayerController.networkconstructor with only first parameterdataSource - then created controller passed to
VlcPlayerwidget
If URL is correct then the video starts playing, but if not it is not clear how to get a particular error from the controller with some meaningful description.
For troubleshooting, I add the next listener to controller:
_playerController.addListener(() {
print('${_playerController.value}');
});
And on Android I got at last some general error in errorDescription, when in VLC log output got precise error description:
E/VLC (30113): [0000007693b0e610/795] http stream: cannot resolve incorrect.url: No address associated with hostname
E/VLC (30113): [0000007693b0e610/795] libvlc stream: HTTP connection failure
I/flutter (30113): VlcPlayerValue(duration: 0:00:00.000000, size: Size(0.0, 0.0), position: 0:00:00.000000, playingState: PlayingState.initialized, isInitialized true, isPlaying: false, isLooping: false, isBuffering: false, isEnded: false, bufferPercent: 0.0, volume: 100, playbackSpeed: 1.0, audioTracksCount: 1, activeAudioTrack: 1, spuTracksCount: 0, activeSpuTrack: -1, errorDescription: )
I/flutter (30113): VlcPlayerValue(duration: 0:00:00.000000, size: Size(0.0, 0.0), position: 0:00:00.000000, playingState: PlayingState.stopped, isInitialized true, isPlaying: false, isLooping: false, isBuffering: false, isEnded: false, bufferPercent: 0.0, volume: 100, playbackSpeed: 1.0, audioTracksCount: 1, activeAudioTrack: 1, spuTracksCount: 0, activeSpuTrack: -1, errorDescription: )
E/VLC (30113): [0000007693b0e610/795] libvlc stream: cannot resolve incorrect.url port 80 : No address associated with hostname
E/VLC (30113): [0000007693b0e610/795] libvlc stream: cannot connect to incorrect.url:80
E/VLC (30113): [0000007693c3bc90/795] libvlc input: Your input can't be opened
E/VLC (30113): [0000007693c3bc90/795] libvlc input: VLC is unable to open the MRL 'http://incorrect.url'. Check the log for details.
I/flutter (30113): VlcPlayerValue(duration: 0:00:00.000000, size: Size(0.0, 0.0), position: 0:00:00.000000, playingState: PlayingState.buffering, isInitialized true, isPlaying: false, isLooping: false, isBuffering: true, isEnded: false, bufferPercent: 0.0, volume: 100, playbackSpeed: 1.0, audioTracksCount: 1, activeAudioTrack: 1, spuTracksCount: 0, activeSpuTrack: -1, errorDescription: )
I/flutter (30113): VlcPlayerValue(duration: 0:00:00.000000, size: Size(0.0, 0.0), position: 0:00:00.000000, playingState: PlayingState.buffering, isInitialized true, isPlaying: false, isLooping: false, isBuffering: false, isEnded: false, bufferPercent: 0.0, volume: 100, playbackSpeed: 1.0, audioTracksCount: 0, activeAudioTrack: -1, spuTracksCount: 0, activeSpuTrack: -1, errorDescription: )
I/flutter (30113): VlcPlayerValue(duration: 0:00:00.000000, size: Size(0.0, 0.0), position: 0:00:00.000000, playingState: PlayingState.error, isInitialized true, isPlaying: false, isLooping: false, isBuffering: false, isEnded: false, bufferPercent: 0.0, volume: 100, playbackSpeed: 1.0, audioTracksCount: 0, activeAudioTrack: -1, spuTracksCount: 0, activeSpuTrack: -1, errorDescription: An Unknown Error Occurred!)
I/flutter (30113): VlcPlayerValue(duration: 0:00:00.000000, size: Size(0.0, 0.0), position: 0:00:00.000000, playingState: PlayingState.stopped, isInitialized true, isPlaying: false, isLooping: false, isBuffering: false, isEnded: false, bufferPercent: 0.0, volume: 100, playbackSpeed: 1.0, audioTracksCount: 0, activeAudioTrack: -1, spuTracksCount: 0, activeSpuTrack: -1, errorDescription: An Unknown Error Occurred!)
But on iOS I got nothing at all except stopped state:
creating player instance using shared library
flutter: VlcPlayerValue(duration: 0:00:00.000000, size: Size(0.0, 0.0), position: 0:00:00.000000, playingState: PlayingState.initialized, isInitialized true, isPlaying: false, isLooping: false, isBuffering: false, isEnded: false, bufferPercent: 0.0, volume: 100, playbackSpeed: 1.0, audioTracksCount: 1, activeAudioTrack: 1, spuTracksCount: 0, activeSpuTrack: -1, errorDescription: )
flutter: VlcPlayerValue(duration: 0:00:00.000000, size: Size(0.0, 0.0), position: 0:00:00.000000, playingState: PlayingState.initialized, isInitialized true, isPlaying: false, isLooping: false, isBuffering: false, isEnded: false, bufferPercent: 100.0, volume: 100, playbackSpeed: 1.0, audioTracksCount: 0, activeAudioTrack: -1, spuTracksCount: 0, activeSpuTrack: -1, errorDescription: )
flutter: VlcPlayerValue(duration: 0:00:00.000000, size: Size(0.0, 0.0), position: 0:00:00.000000, playingState: PlayingState.stopped, isInitialized true, isPlaying: false, isLooping: false, isBuffering: false, isEnded: false, bufferPercent: 100.0, volume: 100, playbackSpeed: 1.0, audioTracksCount: 0, activeAudioTrack: -1, spuTracksCount: 0, activeSpuTrack: -1, errorDescription: )
+1 there should be a way to handle the errors in case a url or path is incorrect.
Did anyone find a solution to this? Maybe a listener for this or something?