3

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:

  1. 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)
  1. 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,
        ),
      ),
    );
  }
}
JustAG33K
  • 1,403
  • 3
  • 13
  • 28
inkwelll075
  • 494
  • 4
  • 19
  • Have you checked whether the video is playing properly in any other live streaming application before playing it in the flutter app. Your error is clear states that its a `Hand Shake failed ` please do check whether the configuration from the video server is proper. – Abdul Kadhar Aug 22 '22 at 07:35
  • @AbdulKadhar it perfeclty works on every device and in browser too but when I try to play it in flutter, it dosen't work – inkwelll075 Aug 22 '22 at 07:53
  • @ArielSorianoVassia hey, yes, I have found solution: I have mjpeg format video stream and it dosen't work properly with video_player package because it can't work with such format itself. So there were two ways: 1. Use ff-mpeg player, which was too complicated for me 2. Use webview package. I used the second solution with this package flutter_inappwebview: ^5.4.4+3 and it works perfcetly. But keep in mind, i have mjpeg video stream (which is quite specific fomat), not mp4 or something else – inkwelll075 Jan 11 '23 at 10:41
  • 1
    @ArielSorianoVassia Also if you can, you should try to use https instead http. When you build your app, video without ssl-certificate and on http will be work only in debug mode. So to prevent it, I highly recommend to use https. Also it saves you from having to add cleartext to your android manifest – inkwelll075 Jan 11 '23 at 10:44

0 Answers0