-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from resucutie/no-mediakit
Replace media_kit with fvp
- Loading branch information
Showing
11 changed files
with
137 additions
and
232 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,58 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:chewie/chewie.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:media_kit/media_kit.dart'; | ||
import 'package:media_kit_video/media_kit_video.dart'; | ||
import 'package:localbooru/utils/platform_tools.dart'; | ||
import 'package:mime/mime.dart'; | ||
import 'package:video_player/video_player.dart'; | ||
|
||
class VideoView extends StatefulWidget { | ||
const VideoView(this.path, {Key? key}) : super(key: key); | ||
const VideoView(this.path, {super.key, this.showControls = true}); | ||
|
||
final String path; | ||
final bool showControls; | ||
|
||
@override | ||
State<VideoView> createState() => VideoViewState(); | ||
} | ||
|
||
class VideoViewState extends State<VideoView> { | ||
late final player = Player(); | ||
late VideoPlayerController _videoController; | ||
late ChewieController _chewieController; | ||
bool _isLoaded = false; | ||
|
||
late final controller = VideoController(player); | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
|
||
player.open(Media(widget.path), play: lookupMimeType(widget.path) == "image/gif"); | ||
player.setPlaylistMode(PlaylistMode.single); | ||
_videoController = VideoPlayerController.file(File(widget.path)) | ||
..initialize().then((value) { | ||
_chewieController = ChewieController( | ||
videoPlayerController: _videoController, | ||
autoPlay: true, | ||
looping: true, | ||
allowFullScreen: false, // apparently full screen calls dispose() | ||
showControls: widget.showControls | ||
); | ||
setState(() { | ||
_isLoaded = true; | ||
}); | ||
},); | ||
} | ||
|
||
@override | ||
void dispose() { | ||
player.dispose(); | ||
_videoController.dispose(); | ||
_chewieController.dispose(); | ||
super.dispose(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return SizedBox( | ||
width: MediaQuery.of(context).size.width, | ||
height: MediaQuery.of(context).size.width, | ||
child: Video(controller: controller, fill: Colors.transparent), | ||
return AspectRatio( | ||
aspectRatio: _videoController.value.aspectRatio, | ||
child: _isLoaded ? Chewie(controller: _chewieController,) : const SizedBox(height: 0,) | ||
); | ||
} | ||
} |
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
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.