neeko icon indicating copy to clipboard operation
neeko copied to clipboard

Issue when enabling autoplay and live

Open fahmih6 opened this issue 5 years ago • 3 comments

Hi. i'm experiencing an issue when enabling Autoplay and Live option. here is the error message.

[38;5;248m════════ Exception caught by widgets library ═══════════════════════════════════[39;49m
[38;5;244mThe following NoSuchMethodError was thrown building Positioned(left: 0.0, right: 0.0, bottom: 0.0):[39;49m
The method 'addListener' was called on null.
Receiver: null
Tried calling: addListener(Closure: () => Null)

[38;5;244mThe relevant error-causing widget was[39;49m
    [38;5;248mNeekoPlayerWidget[39;49m
[38;5;244mWhen the exception was thrown, this was the stack[39;49m
[38;5;244m#0      Object.noSuchMethod  (dart:core-patch/object_patch.dart:53:5)[39;49m
[38;5;248m#1      _LiveBottomBarState._attachListenerToController[39;49m
[38;5;248m#2      _LiveBottomBarState.initState[39;49m
[38;5;244m#3      StatefulElement._firstBuild[39;49m
[38;5;244m#4      ComponentElement.mount[39;49m
[38;5;244m...[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m

[38;5;248m════════ Exception caught by widgets library ═══════════════════════════════════[39;49m
The method 'addListener' was called on null.
Receiver: null
Tried calling: addListener(Closure: () => Null)
[38;5;244mThe relevant error-causing widget was[39;49m
    [38;5;248mNeekoPlayerWidget[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m

[38;5;248m════════ Exception caught by widgets library ═══════════════════════════════════[39;49m
The method 'addListener' was called on null.
Receiver: null
Tried calling: addListener(Closure: () => Null)
[38;5;244mThe relevant error-causing widget was[39;49m
    [38;5;248mNeekoPlayerWidget[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m

[38;5;248m════════ Exception caught by widgets library ═══════════════════════════════════[39;49m
The method 'addListener' was called on null.
Receiver: null
Tried calling: addListener(Closure: () => Null)
[38;5;244mThe relevant error-causing widget was[39;49m
    [38;5;248mNeekoPlayerWidget[39;49m
[38;5;248m════════════════════════════════════════════════════════════════════════════════[39;49m

Here is my code :

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:neeko/neeko.dart';
import 'package:flutter/foundation.dart';

class PlayerPage extends StatefulWidget {
  PlayerPage({Key key, @required this.url, @required this.title})
      : super(key: key);

  final String url;
  final String title;

  @override
  _PlayerPageState createState() => _PlayerPageState();
}

class _PlayerPageState extends State<PlayerPage> {
  VideoControllerWrapper videoControllerWrapper;

  @override
  void initState() {
    super.initState();
    videoControllerWrapper = VideoControllerWrapper(
        DataSource.network(widget.url, displayName: widget.title));
    SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.top]);
  }

  @override
  void dispose() {
    SystemChrome.restoreSystemUIOverlays();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: NeekoPlayerWidget(
        playerOptions: NeekoPlayerOptions(autoPlay: true, isLive: true),
        videoControllerWrapper: videoControllerWrapper,
      ),
    );
  }
}

The player's works perfectly if i set the autoplay and live to false tho.

fahmih6 avatar Dec 31 '19 17:12 fahmih6

The problem seems to be that something wrong when changing videoPlayer. Actually video_player work with native players. And as a result, we can't release players as soon as possible and at that time the ChangeNotifier was disposed or null. I think this is the problem and I'm trying to solve this.

JarvanMo avatar Jan 02 '20 06:01 JarvanMo

Hello, I am having the same problem, I would like to know if it has been solved? analyzing the issue, I see that the problem may be the progress bar of the duration of the video, I see that the error occurs at the moment that a stream file (.m3u8) ends and a new one begins, because that's when the progressbar cannot find the start and end parameters of the video; which does not happen when the file extension is mp4 and the option "isLive = true" is left because it only happens at the beginning of the video and then it is corrected. I guess a solution would be to disable or set the ProgressBar fixed cause its a LiveStream and such animation is not necessary, I hope that my opinion has been understood, I will be waiting for an answer because this package is important for my project. Thank you.

atjosue avatar Feb 24 '20 15:02 atjosue

just change the "_attachListenerToController()" function located in the video_controller_widgets.dart() file to the following code:

_attachListenerToController() { if(controller!=null){ controller.addListener( () { if (controller.value.duration == null || controller.value.position == null) { return; } if (mounted) { setState(() { _currentPosition = controller.value.position.inMilliseconds; _currentSliderPosition = controller.value.position.inMilliseconds / controller.value.duration.inMilliseconds; }); } }, ); } }

If the problem persists, just delete the slider located in the widget's constructor. You also have to set the "Loop = true" and "autoPlay=false".

atjosue avatar Feb 26 '20 21:02 atjosue