我试图使用flutter_vlc_player实现全屏,但由于它始终返回“already initialized”,所以无法完成。那么我该如何获得相同的VLC播放器实例以在全屏模式下显示?
VLCPlayer
放在一个 AspectRatio
中,如果您想要调整视频大小,则可以选择将其放在 Transform
中。
由于 flutter_vlc_player
插件在某些方面表现不直观,我已经在 Github 上准备了一个示例项目来演示设置。
假设您的应用程序以横向模式显示,并且视频是16/9格式:
final screenSize = MediaQuery.of(context).size;
final vlcPlayer = VlcPlayer(
controller: vlcController,
aspectRatio: screenSize.width / screenSize.height,
placeholder: const Center(child: CircularProgressIndicator()));
Scaffold(
body: Stack(
children: [
Container(
// Background behind the video
color: Colors.black,
),
Center(
child: AspectRatio(aspectRatio: 16 / 9, child: vlcPlayer)),
],
),
)
只需将 vlc_player_controller.dart 中 initialize 方法中的 "throw Exception('Already Initialized');" 这一行注释掉即可。
Future<void> initialize() async {
if (value.isInitialized) {
// throw Exception('Already Initialized');
}....
}