flutter_packages
flutter_packages copied to clipboard
[ BUG ] : VideoPlayerController is not working
Plugin name E.Appinio Video Player
Describe the bug
I imported the video player and tried using VideoPlayerController inside the GetXController but I am getting an error in that
To Reproduce Steps to reproduce the behavior:
- import the package and try using VideoPlayerController you will get the issue
Smartphone (please complete the following information):
- Device: [iPhone15 Pro Max]
Same issue after 1.3.0 update
i recommend to use ^1.2.2. solved my problem.
In 1.3.0
, it seems the CachedVideoPlayerController
is the go-to video controller that is available when using the package.
See the updated example provided in the package: https://github.com/appinioGmbH/flutter_packages/blob/2b13f21bc2a273be05605bf60f3ee85862e95fab/packages/appinio_video_player/example/lib/main.dart#L33
That is my problem. I get the following error when I build:
../storyflix/lib/src/widgets/movie_player.dart:18:8: Error: Type 'CachedVideoPlayerController' not found.
late CachedVideoPlayerController _videoPlayerController;
^^^^^^^^^^^^^^^^^^^^^^^^^^^
../storyflix/lib/src/widgets/movie_player.dart:18:8: Error: 'CachedVideoPlayerController' isn't a type.
late CachedVideoPlayerController _videoPlayerController;
^^^^^^^^^^^^^^^^^^^^^^^^^^^
../storyflix/lib/src/widgets/movie_player.dart:24:9: Error: The getter 'CachedVideoPlayerController' isn't defined for the class '_MoviePlayerState'.
- '_MoviePlayerState' is from 'package:storyflix/src/widgets/movie_player.dart' ('../storyflix/lib/src/widgets/movie_player.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'CachedVideoPlayerController'.
I have tried cleaning and repairing the cache to no avail. I though it might be my IDE, but I get the error in both VS Code and in Android Studio.
This is the code:
import 'package:appinio_video_player/appinio_video_player.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
class MoviePlayer extends StatefulWidget {
final Uri videoUrl;
final String title;
const MoviePlayer({super.key, required this.videoUrl, required this.title});
@override
State<MoviePlayer> createState() => _MoviePlayerState();
}
class _MoviePlayerState extends State<MoviePlayer> {
late CustomVideoPlayerWebController _customVideoPlayerWebController;
late CustomVideoPlayerController _customVideoPlayerController;
late CachedVideoPlayerController _videoPlayerController;
@override
void initState() {
super.initState();
_videoPlayerController =
CachedVideoPlayerController.network(widget.videoUrl.toString());
if (kIsWeb) {
_customVideoPlayerWebController = CustomVideoPlayerWebController(
webVideoPlayerSettings: CustomVideoPlayerWebSettings(
src: widget.videoUrl.toString(),
));
} else {
_customVideoPlayerController = CustomVideoPlayerController(
context: context, videoPlayerController: _videoPlayerController);
}
}
@override
void dispose() {
super.dispose();
if (!kIsWeb) {
_customVideoPlayerController.dispose();
_videoPlayerController.dispose();
}
}
@override
Widget build(BuildContext context) {
Widget videoPlayer = kIsWeb
? CustomVideoPlayerWeb(
customVideoPlayerWebController: _customVideoPlayerWebController,
)
: CustomVideoPlayer(
customVideoPlayerController: _customVideoPlayerController);
return Center(
child: videoPlayer,
);
}
}
and the output of flutter doctor -v
[√] Flutter (Channel stable, 3.19.5, on Microsoft Windows [Version 10.0.22631.3447], locale en-US)
• Flutter version 3.19.5 on channel stable at C:\tools\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 300451adae (6 weeks ago), 2024-03-27 21:54:07 -0500
• Engine revision e76c956498
• Dart version 3.3.3
• DevTools version 2.31.1
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at C:\Users\gbrew\AppData\Local\Android\sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
• Java version OpenJDK Runtime Environment (build 17.0.10+0--11572160)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.9.6)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.9.34728.123
• Windows 10 SDK version 10.0.22621.0
[√] Android Studio (version 2023.3)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.10+0--11572160)
[√] VS Code, 64-bit edition (version 1.89.0)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension version 3.88.0
[√] Connected device (5 available)
• Pixel 7 Pro (mobile) • 2C121FDH3S0KW7 • android-arm64 • Android 14 (API 34)
• SM G965U (mobile) • 4359524452413098 • android-arm64 • Android 10 (API 29)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22631.3447]
• Chrome (web) • chrome • web-javascript • Google Chrome 124.0.6367.119
• Edge (web) • edge • web-javascript • Microsoft Edge 124.0.2478.80
[√] Network resources
• All expected network resources are available.
• No issues found!
That is my problem. I get the following error when I build:
You need to use CachedVideoPlayerPlusController
instead of CachedVideoPlayerController
I think there should be an update in the naming convention for this.