flutter 在youtube播放器中,通过按下全屏按钮,从横向模式返回纵向模式时,状态栏会被隐藏

j2qf4p5b  于 2022-11-17  发布在  Flutter
关注(0)|答案(2)|浏览(308)

当你按下youtube播放器的全屏按钮时,它会进入横向模式,当你再次按下它时,它会回到纵向模式,但状态栏会永久隐藏在整个应用程序中。
如果有人知道**如何在纵向模式下显示状态栏。**请让我知道。谢谢!
代码如下:

import 'package:flutter/material.dart';
import 'package:youtube_player_flutter/youtube_player_flutter.dart';

/// Creates list of video players
class VideoList extends StatefulWidget {
  @override
  _VideoListState createState() => _VideoListState();
}

class _VideoListState extends State<VideoList> {
  final List<YoutubePlayerController> _controllers = [
    'K4TOrB7at0Y',
  ]
      .map<YoutubePlayerController>(
        (videoId) => YoutubePlayerController(
          initialVideoId: videoId,
          flags: const YoutubePlayerFlags(
            autoPlay: false,
          ),
        ),
      )
      .toList();

  @override
  Widget build(BuildContext context) {
    return YoutubePlayerBuilder(
      player: YoutubePlayer(controller: _controllers.first),
      builder: (p0, p1) {
        return Scaffold(
          appBar: AppBar(
            title: Text('Video Player'),
          ),
          body: Column(children: [
            p1,
          ]),
        );
      },
    );
  }
}

输出:https://drive.google.com/file/d/1TkuDkLVflFGBNv90Tywh6CuCN3BK0EG_/view?usp=sharing x1c 0d1x谢谢!

ogq8wdun

ogq8wdun1#

我认为你应该把脚手架包在Youtube播放器构建器外面。

thtygnil

thtygnil2#

只需将SystemUiOverlay.top添加到YoutubePlayerBuilderonEnterFullScreen回调中,即可按照以下方式持久显示状态栏。

onEnterFullScreen: () {
      SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: [
        SystemUiOverlay.top,
      ]);
}

构建方法

@override
  Widget build(BuildContext context) {
    return YoutubePlayerBuilder(
      onEnterFullScreen: () {
        SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: [
          SystemUiOverlay.top,
        ]);
      },
      player: YoutubePlayer(controller: _controllers.first),
      builder: (p0, p1) {
        return Scaffold(
          appBar: AppBar(
            title: Text('Video Player'),
          ),
          body: Column(children: [
            p1,
          ]),
        );
      },
    );
  }

相关问题