Closed BTMuli closed 7 months ago
I think this issue is not related with video_player_win
package.
In your bangumi_play.dart
,
there are two lines:
import 'package:fluent_ui/fluent_ui.dart' hide StatelessWidget;
import 'package:flutter/material.dart' show MaterialApp, Scaffold, StatelessWidget;
Please edit as below:
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/material.dart';
I think this issue is not related with
video_player_win
package.
Nop,I use the two lines since when I use JkVideoControlPanel
as a SizedBox.child
,it throw err:
======== Exception caught by widgets library =======================================================
The following assertion was thrown building Slider(value: 0.0, secondaryTrackValue: null, min: 0.0, max: 1430117.0, divisions: null, label: null, activeColor: null, inactiveColor: null, secondaryActiveColor: null, has focusNode, dirty, state: _SliderState#c39d1(tickers: tracking 4 tickers)):
No Material widget found.
...
The relevant error-causing widget was:
JkVideoControlPanel JkVideoControlPanel:file:///D:/Code/App/bangumi_today/lib/pages/bangumi/bangumi_play.dart:104:20
When the exception was thrown, this was the stack:
#0 debugCheckHasMaterial.<anonymous closure> (package:flutter/src/material/debug.dart:38:7)
#1 debugCheckHasMaterial (package:flutter/src/material/debug.dart:63:4)
#2 _SliderState.build (package:flutter/src/material/slider.dart:755:12)
#3 StatefulElement.build (package:flutter/src/widgets/framework.dart:5592:27)
#4 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5480:15)
#5 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5643:11)
#6 Element.rebuild (package:flutter/src/widgets/framework.dart:5196:7)
#7 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:5462:5)
#8 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:5634:11)
#9 ComponentElement.mount (package:flutter/src/widgets/framework.dart:5456:5)
... Normal element mounting (18 frames)
#27 Element.inflateWidget (package:flutter/src/widgets/framework.dart:4335:16)
#28 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6893:36)
#29 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6905:32)
... Normal element mounting (19 frames)
#48 Element.inflateWidget (package:flutter/src/widgets/framework.dart:4335:16)
#49 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6893:36)
#50 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6905:32)
... Normal element mounting (15 frames)
#65 Element.inflateWidget (package:flutter/src/widgets/framework.dart:4335:16)
#66 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6893:36)
#67 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6905:32)
... Normal element mounting (29 frames)
#96 Element.inflateWidget (package:flutter/src/widgets/framework.dart:4335:16)
#97 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6893:36)
#98 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6905:32)
... Normal element mounting (36 frames)
#134 Element.inflateWidget (package:flutter/src/widgets/framework.dart:4335:16)
#135 Element.updateChild (package:flutter/src/widgets/framework.dart:3840:20)
#136 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6765:14)
#137 Element.updateChild (package:flutter/src/widgets/framework.dart:3824:15)
#138 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5505:16)
#139 Element.rebuild (package:flutter/src/widgets/framework.dart:5196:7)
#140 ProxyElement.update (package:flutter/src/widgets/framework.dart:5809:5)
#141 Element.updateChild (package:flutter/src/widgets/framework.dart:3824:15)
#142 Element.updateChildren (package:flutter/src/widgets/framework.dart:3973:32)
#143 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6918:17)
#144 Element.updateChild (package:flutter/src/widgets/framework.dart:3824:15)
#145 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6765:14)
#146 Element.updateChild (package:flutter/src/widgets/framework.dart:3824:15)
#147 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5505:16)
#148 Element.rebuild (package:flutter/src/widgets/framework.dart:5196:7)
#149 StatelessElement.update (package:flutter/src/widgets/framework.dart:5556:5)
#150 Element.updateChild (package:flutter/src/widgets/framework.dart:3824:15)
#151 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5505:16)
#152 Element.rebuild (package:flutter/src/widgets/framework.dart:5196:7)
#153 ProxyElement.update (package:flutter/src/widgets/framework.dart:5809:5)
#154 Element.updateChild (package:flutter/src/widgets/framework.dart:3824:15)
#155 Element.updateChildren (package:flutter/src/widgets/framework.dart:3973:32)
#156 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6918:17)
#157 Element.updateChild (package:flutter/src/widgets/framework.dart:3824:15)
#158 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6765:14)
#159 Element.updateChild (package:flutter/src/widgets/framework.dart:3824:15)
#160 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5505:16)
#161 Element.rebuild (package:flutter/src/widgets/framework.dart:5196:7)
#162 StatelessElement.update (package:flutter/src/widgets/framework.dart:5556:5)
#163 Element.updateChild (package:flutter/src/widgets/framework.dart:3824:15)
#164 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5505:16)
#165 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5643:11)
#166 Element.rebuild (package:flutter/src/widgets/framework.dart:5196:7)
#167 StatefulElement.update (package:flutter/src/widgets/framework.dart:5666:5)
#168 Element.updateChild (package:flutter/src/widgets/framework.dart:3824:15)
#169 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5505:16)
#170 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5643:11)
#171 Element.rebuild (package:flutter/src/widgets/framework.dart:5196:7)
#172 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2904:19)
#173 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:989:21)
#174 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:448:5)
#175 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1386:15)
#176 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1311:9)
#177 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1169:5)
#178 _invoke (dart:ui/hooks.dart:312:13)
#179 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:399:5)
#180 _drawFrame (dart:ui/hooks.dart:283:31)
====================================================================================================
[video_player_win] load fail, reload now
And when I use Scaffold
to contain it,the panel render but the player throw:
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument(s): video file not opened yet
#0 WinVideoPlayerController.pause (package:video_player_win/video_player_win.dart:235:31)
#1 WindowsVideoPlayer.pause (package:video_player_win/video_player_win_plugin.dart:96:23)
#2 VideoPlayerController._applyPlayPause (package:video_player/video_player.dart:586:34)
#3 VideoPlayerController.pause (package:video_player/video_player.dart:547:11)
#4 _JkVideoControlPanelState.togglePlayPause (package:video_player_control_panel/video_player_control_panel.dart:296:25)
#5 _JkVideoControlPanelState.createPlayPauseButton.<anonymous closure>.<anonymous closure> (package:video_player_control_panel/video_player_control_panel.dart:352:15)
#6 _InkResponseState.handleTap (package:flutter/src/material/ink_well.dart:1183:21)
#7 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:315:24)
#8 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:652:11)
#9 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:309:5)
#10 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:242:7)
#11 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:670:9)
#12 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:98:12)
#13 PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:143:9)
#14 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:633:13)
#15 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:141:18)
#16 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:127:7)
#17 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:495:19)
#18 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:475:22)
#19 RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:430:11)
#20 GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:420:7)
#21 GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:383:5)
#22 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:330:7)
#23 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:299:9)
#24 _invoke1 (dart:ui/hooks.dart:328:13)
#25 PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:429:7)
#26 _dispatchPointerDataPacket (dart:ui/hooks.dart:262:31)
return Center(
child: Card(
padding: EdgeInsets.zero,
margin: EdgeInsets.symmetric(
vertical: 16.w,
horizontal: 16.h,
),
child: AspectRatio(
aspectRatio: 16 / 9,
child: SizedBox.expand(
child: Scaffold(
body: JkVideoControlPanel(
controller,
showClosedCaptionButton: true,
showFullscreenButton: false,
showVolumeButton: true,
),
),
),
),
),
);
}
The following code works well for me.
The JkVideoControlPanel
is wrapped in FluentApp & Card, and it works well.
Please remember to edit the file path in the code when you run.
So I think JkVideoControlPanel
works well with FluentApp
& Card
.
If you still encounter any errors, please give me a simple (as simple as possible) sample code.
import 'dart:io';
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/material.dart' hide Card;
import 'package:video_player/video_player.dart';
import 'package:video_player_control_panel/video_player_control_panel.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
final controller = VideoPlayerController.file(File("E:\\test_youtube.mp4"));
controller.initialize().then((value) {
controller.play();
});
return FluentApp(
home: Scaffold(
body: Card(
child: AspectRatio(
aspectRatio: 16 / 9,
child: SizedBox.expand(
child: JkVideoControlPanel(controller),
)))));
}
}
It works amazing🥰
return material.Scaffold(
body: Card(
child: AspectRatio(
aspectRatio: 16 / 9,
child: JkVideoControlPanel(
controller,
showClosedCaptionButton: true,
showFullscreenButton: false,
showVolumeButton: true,
),
),
),
);
Is it could use in fluent_ui widget directly instead of hide widget in fluent_ui?