-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
890ffc8
commit ffa68f7
Showing
10 changed files
with
283 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:media_kit/media_kit.dart'; | ||
import 'package:media_kit_video/media_kit_video.dart'; | ||
|
||
class VideoDialog extends StatefulWidget { | ||
const VideoDialog({super.key, required this.url}); | ||
|
||
final String url; | ||
|
||
@override | ||
State<VideoDialog> createState() => _VideoDialogState(); | ||
} | ||
|
||
class _VideoDialogState extends State<VideoDialog> { | ||
late final player = Player(); | ||
late final controller = VideoController(player); | ||
double aspectRatio = 1; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
player.open(Media(widget.url)); | ||
controller.rect.addListener(() { | ||
final rect = controller.rect.value; | ||
if (rect == null || rect.width == 0 || rect.height == 0) { | ||
return; | ||
} | ||
setState(() { | ||
aspectRatio = rect.width / rect.height; | ||
}); | ||
}); | ||
} | ||
|
||
@override | ||
void dispose() { | ||
player.dispose(); | ||
super.dispose(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final themeData = MaterialVideoControlsThemeData( | ||
seekBarPositionColor: Theme.of(context).primaryColor, | ||
seekBarThumbColor: Theme.of(context).primaryColor, | ||
); | ||
return AlertDialog( | ||
contentPadding: EdgeInsets.zero, | ||
insetPadding: EdgeInsets.zero, | ||
content: AspectRatio( | ||
aspectRatio: aspectRatio, | ||
child: MaterialVideoControlsTheme( | ||
normal: themeData, | ||
fullscreen: themeData, | ||
child: Video(controller: controller), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.