Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when enabling autoplay and live #8

Open
fahmih6 opened this issue Dec 31, 2019 · 3 comments
Open

Issue when enabling autoplay and live #8

fahmih6 opened this issue Dec 31, 2019 · 3 comments

Comments

@fahmih6
Copy link

fahmih6 commented Dec 31, 2019

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.

@JarvanMo
Copy link
Member

JarvanMo commented Jan 2, 2020

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.

@atjosue
Copy link

atjosue commented Feb 24, 2020

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
Copy link

atjosue commented Feb 26, 2020

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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants