Error when setting autoPlay: false
════════ Exception caught by gesture ═══════════════════════════════════════════════════════════════ The following NoSuchMethodError was thrown while handling a gesture: The getter '_duration' was called on null. Receiver: null Tried calling: _duration
When the exception was thrown, this was the stack: #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5) #1 Duration.>= (dart:core/duration.dart:173:63) #2 _CupertinoControlsState._playPause (package:chewie/src/cupertino_controls.dart:498:45) #3 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24) #4 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:365:11) ... Handler: "onTap" Recognizer: TapGestureRecognizer#d9726 debugOwner: GestureDetector state: ready won arena finalPosition: Offset(49.5, 619.5) finalLocalPosition: Offset(10.5, 18.5) sent tap down ════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (2) Exception caught by gesture ═══════════════════════════════════════════════════════════ The getter '_duration' was called on null. Receiver: null Tried calling: _duration ════════════════════════════════════════════════════════════════════════════════════════════════════
same issue here
same issue
Work around: autoInitialize: true
I created a pull request a couple weeks ago that fixes this issue. It has yet to be approved.
Got same error on real ios device, is there any update? IOS REAL DEVICE When i am trying to playing the video from a video file, it is displaying nothing just a blank screen with controls. and when i am pressing the play button, then i getting the following exception. Note : When i am playing video from http link, then video is playing fine. ANDROID REAL DEVICE It is working fine.
flutter doctor
#Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel unknown, v1.9.1+hotfix.6, on Mac OS X 10.15.1 19B88, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.2.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 3.5)
[✓] Connected device (3 available)
• No issues found!
Pubspec.yaml
chewie: 0.9.8
video_player: 0.10.4+1
I got the same issue on IOS Real device, Is there any updates?
════════ Exception caught by gesture ═══════════════════════════════════════════
The following NoSuchMethodError was thrown while handling a gesture:
The getter '_duration' was called on null.
Receiver: null
Tried calling: _duration
When the exception was thrown, this was the stack
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
#1 Duration.>= (dart:core/duration.dart:173:63)
#2 _CupertinoControlsState._playPause
package:chewie/src/cupertino_controls.dart:498
#3 GestureRecognizer.invokeCallback
package:flutter/…/gestures/recognizer.dart:182
#4 TapGestureRecognizer._checkUp
package:flutter/…/gestures/tap.dart:365
...
Handler: "onTap"
Recognizer: TapGestureRecognizer#c6b94
debugOwner: GestureDetector
state: ready
won arena
finalPosition: Offset(59.5, 733.0)
finalLocalPosition: Offset(12.5, 9.5)
sent tap down
════════════════════════════════════════════════════════════════════════════════
Code of my video class
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:portfolio/Models/FileData.dart';
import 'package:portfolio/Models/globals.dart';
import 'package:portfolio/appbar/appbar.dart';
import 'package:portfolio/repositories/root_repo.dart';
import 'package:video_player/video_player.dart';
import 'package:chewie/chewie.dart';
class VideoPlayerScreen extends StatefulWidget {
final FileData fileData;
VideoPlayerScreen({
@required this.fileData, Key key
}) : super(key: key);
@override
_VideoPlayerScreenState createState() => _VideoPlayerScreenState();
}
class _VideoPlayerScreenState extends State<VideoPlayerScreen> {
Global globalVariables;
VideoPlayerController controller;
File videoFile;
String rootPath;
ChewieController _chewieController;
@override
void initState() {
super.initState();
if(Root.rootObject.rootPath == "" )
{
Root.rootObject.getRootPath();
}
videoFile = File(Root.rootObject.rootPath + "/" + widget.fileData.name);
bool fileExist = new File(videoFile.path).existsSync();
print(fileExist);
print(videoFile.path);
controller = new VideoPlayerController.file(videoFile);
_chewieController = new ChewieController(
videoPlayerController: controller,
aspectRatio: 16 / 9,
autoInitialize: true,
looping: true,
/*errorBuilder: (context, errorMessage){
return Center(
child: Text(
errorMessage = "Sorry, video is not avaiable!!!",
style: TextStyle(color: Colors.black),
)
);
},*/
);
}
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
globalVariables = new Global(size);
return Stack(children: <Widget>[
Center(
child: Container(
decoration: BoxDecoration(
color: globalVariables.backgroundColor,
),
child: Image.asset(
'assets/bg.png',
width: size.width,
height: size.height,
fit: BoxFit.fill,
))),
Scaffold(
backgroundColor: Colors.transparent,
appBar: MyAppBar(
// titleText: Text('Butterfly Video'),
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Chewie(
controller: _chewieController,
),
)
)]
);
}
@override
void dispose() {
// IMPORTANT to dispose of all the used resources
controller.dispose();
_chewieController.dispose();
super.dispose();
}
}
setting autoPlay: false,
autoInitialize: true, might do the trick
Hi, i'm facing the same issue (the getter _duration was called on null) and solutions mentioned above didn't help me fix it. Everything was working fine until i updated packages (chewie and videoplayer). Does somebody have other suggestions how to fix this error? Thanks in advance.
Hi, i'm facing the same issue (the getter _duration was called on null) and solutions mentioned above didn't help me fix it. Everything was working fine until i updated packages (chewie and videoplayer). Does somebody have other suggestions how to fix this error? Thanks in advance.
after downgrading back to chewie 0.9.10 and videoplayer 0.10.12+5 , the issue is gone.
@pasty161 Can you provide a minimal example for which this is failing? Thanks
setting
autoPlay: false, autoInitialize: true,might do the trick
Unfortunately this doesn't help. The duration error is still there.
setting
autoPlay: false, autoInitialize: true,might do the trick
Still Not Working. 😞
I think it is a problem in flutter video widget. Please read this https://github.com/flutter/flutter/issues/48670 there are some workarounds to force video player initialization even if the duration is unknown (live streams for example). The problem seems to appear only on iOS
@maoamid The link sends you to chewies issue. ^^ https://github.com/flutter/flutter/issues/48670
@nstrelow my mistake, I updated the link. Thank you!
I think it is a problem in flutter video widget. Please read this flutter/flutter#48670 there are some workarounds to force video player initialization even if the duration is unknown (live streams for example). The problem seems to appear only on iOS
The problem described above is in fact with this plugin - specifically in cupertino_controls.dart
You'll notice that in material_controls.dart build function there are checks to make sure nothing is loaded if duration == null
children: <Widget>[
_latestValue != null &&
!_latestValue.isPlaying &&
_latestValue.duration == null ||
_latestValue.isBuffering
? const Expanded(
child: const Center(
child: const CircularProgressIndicator(),
),
)
: _buildHitArea(),
There is no such check in cupertino_controls.dart
children: <Widget>[
_buildTopBar(
backgroundColor, iconColor, barHeight, buttonPadding),
_buildHitArea(),
If you force load material controls on iOS you no longer get the The getter '_duration' was called on null. error.
I'm using a workaround to get HLS videos to load in iOS (per flutter/plugins#48670) but was still getting the _duration error in chewie using the latest version - some digging and I found the above discrepancies between cupertino and material controls.
I think it is a problem in flutter video widget. Please read this flutter/flutter#48670 there are some workarounds to force video player initialization even if the duration is unknown (live streams for example). The problem seems to appear only on iOS
The problem described above is in fact with this plugin - specifically in
cupertino_controls.dartYou'll notice that in
material_controls.dartbuild function there are checks to make sure nothing is loaded if duration == nullchildren: <Widget>[ _latestValue != null && !_latestValue.isPlaying && _latestValue.duration == null || _latestValue.isBuffering ? const Expanded( child: const Center( child: const CircularProgressIndicator(), ), ) : _buildHitArea(),There is no such check in
cupertino_controls.dartchildren: <Widget>[ _buildTopBar( backgroundColor, iconColor, barHeight, buttonPadding), _buildHitArea(),If you force load material controls on iOS you no longer get the
The getter '_duration' was called on null.error.I'm using a workaround to get HLS videos to load in iOS (per flutter/plugins#48670) but was still getting the _duration error in chewie using the latest version - some digging and I found the above discrepancies between cupertino and material controls.
@nathanaelneveux thanks a lot, you helped me with this obsesrvation. Merry Christmas!
This should be fixed with 0.12.1