I set up everything as it said in the docs of video_player, but I still got this error. I also configured network security to prevent cleartext error, so now I have got this issue with playing live stream video. Important note: this live stream goes from websockets and I suppose this streaming issue can be related to it, but I am not really sure. So the first step I was trying is:
- Instead of http use https (as it was answered in this question No Network Security Config specified, using platform default - Android Log) also I configured all files as it desicribed in answers of this question.
but I am still facing the error:
Playback error
E/ExoPlayerImplInternal( 8519): com.google.android.exoplayer2.ExoPlaybackException: Source error
Caused by: com.google.android.exoplayer2.upstream.HttpDataSource$HttpDataSourceException: javax.net.ssl.SSLHandshakeException: Handshake failed
Caused by: javax.net.ssl.SSLHandshakeException: Handshake failed
Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x7d53758448: Failure in SSL library, usually a protocol error
E/ExoPlayerImplInternal( 8519): error:100000f7:SSL routines:OPENSSL_internal:WRONG_VERSION_NUMBER (external/boringssl/src/ssl/tls_record.cc:242 0x7dd5d25e6b:0x00000000)
When I use http (as it is in original link) I have got this errors:
Caused by: com.google.android.exoplayer2.source.UnrecognizedInputFormatException: None of the available extractors (FlvExtractor, FlacExtractor, WavExtractor, FragmentedMp4Extractor, Mp4Extractor, AmrExtractor, PsExtractor, OggExtractor, TsExtractor, MatroskaExtractor, AdtsExtractor, Ac3Extractor, Ac4Extractor, Mp3Extractor, AviExtractor, JpegExtractor) could read the stream.
My code is pretty simple and basic because I got it from official flutter video_player documentation and didn't make any fancy stuff:
class _VideoPlayerScreenState extends State<VideoPlayerScreen> {
late VideoPlayerController _controller;
late Future<void> _initializeVideoPlayerFuture;
@override
void initState() {
super.initState();
_controller = VideoPlayerController.network(
'http://10.10:8000/home/LiveCamera',
);
_initializeVideoPlayerFuture = _controller.initialize();
_controller.setLooping(true);
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: FutureBuilder(
future: _initializeVideoPlayerFuture,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
return AspectRatio(
aspectRatio: _controller.value.aspectRatio,
child: VideoPlayer(_controller),
);
} else {
return const Center(
child: CircularProgressIndicator(),
);
}
},
),
floatingActionButton: FloatingActionButton(
onPressed: () {
setState(() {
if (_controller.value.isPlaying) {
_controller.pause();
} else {
_controller.play();
}
});
},
child: Icon(
_controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
),
),
);
}
}