solid-software / flutter_vlc_player

📺 Flutter VLC powered video player.
524 stars 253 forks source link

unable to get controller.value on android #458

Open mzkaoq opened 11 months ago

mzkaoq commented 11 months ago

does anyone has similar problem with vlc_player running with android platform?

*with IOS it works fine and I get normal size values etc,

i am getting this return when I call ` _controller.addListener(() async { var streamValue = _controller.value;

  print(streamValue);

});`

I/flutter (11395): VlcPlayerValue(duration: 0:00:00.000000, size: Size(0.0, 0.0), position: 0:00:00.000000, playingState: PlayingState.playing, isInitialized true, isPlaying: true, isLooping: false, isBuffering: false, isEnded: false, isRecording: false, bufferPercent: 0.0, volume: 100, playbackSpeed: 1.0, audioTracksCount: 0, activeAudioTrack: -1, spuTracksCount: 0, activeSpuTrack: -1, recordPath: , errorDescription: )

additionally something like that was printed at the start of the logs, does it matter?

E/VLC (11395): [b400007119104b40/2d00] libvlc window: request 1 not implemented E/VLC (11395): [b400007119103120/2d00] libvlc gl: shader 0: WARNING: 0:3: extension 'GL_EXT_gpu_shader5' is not supported

code

      class _HTTPstreamerState extends State<HTTPstreamer> {
      late VlcPlayerController _controller;
      late Size screenSize;
      double aspectRatio = 0.1;
      bool getReady = false;

      @override
      void initState() {
        super.initState();
      _controller = VlcPlayerController.network(
        autoPlay: true,
        autoInitialize: true,
        widget.urlAdress,
        hwAcc: HwAcc.full,
        options: VlcPlayerOptions(
          advanced: VlcAdvancedOptions([
            VlcAdvancedOptions.networkCaching(2000),
          ]),
          http: VlcHttpOptions([
            VlcHttpOptions.httpReconnect(true),
          ]),
          rtp: VlcRtpOptions([
            VlcRtpOptions.rtpOverRtsp(true),
          ]),
        ),
      );
      _controller.addOnInitListener(() async {
        await _controller.startRendererScanning();
      });
      _controller.addOnRendererEventListener((type, id, name) {
        debugPrint('OnRendererEventListener $type $id $name');
      });

      //TODO after set state we can remove listener but idk how to do that :(
      _controller.addListener(() async {
        var streamValue = _controller.value;

        print(streamValue);

      });

      }

      @override
      void dispose() async {
        super.dispose();
        await _controller.stopRendererScanning();
        await _controller.dispose();
      }

      @override
      Widget build(BuildContext context) {
        screenSize = MediaQuery.of(context).size;
        return Center(
            child: SizedBox(
          width: screenSize.width * 9 / 16 * aspectRatio,
          height: screenSize.width * 9 / 16,
          child: VlcPlayer(
              controller: _controller,
              aspectRatio: aspectRatio,
              placeholder: const Center(child: CircularProgressIndicator())),
        ));
      }
    }
adilmehmood-md commented 8 months ago

@mzkaoq found any solution for this?

bllaw commented 6 months ago

I have to do this:

void listener() { if (!mounted) return; if (_controller.value.isPlaying) { // get size width length etc } }