Skip to content

Commit

Permalink
移动端播放器全屏时可以切换竖屏播放 Close #28
Browse files Browse the repository at this point in the history
  • Loading branch information
chivehao committed Aug 30, 2024
1 parent f525e15 commit a8a692e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- 条目列表根据条目类型筛选
- 修复收藏页条目无法完全展示的问题
- 移动端播放器全屏时可以切换竖屏播放 #28

# 15.3.6

Expand Down
27 changes: 23 additions & 4 deletions lib/player/player_video_mobile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class MobileVideoPlayerState extends State<MobileVideoPlayer>
final ThrottleController _throttleController = ThrottleController();
late DanmuConfig _danmuConfig = DanmuConfig();
late bool _danmuConfigChange = false;
late bool _isFullScreenPortraitUp = false;

void listener() {
if (!mounted) return;
Expand Down Expand Up @@ -690,6 +691,7 @@ class MobileVideoPlayerState extends State<MobileVideoPlayer>
/// 视频
SizedBox(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
child: VlcPlayer(
controller: _player,
aspectRatio: 16 / 9,
Expand Down Expand Up @@ -731,7 +733,7 @@ class MobileVideoPlayerState extends State<MobileVideoPlayer>
child: Stack(
children: [
// 上方中间的标题文本
if (_isFullScreen)
if (_isFullScreen || _isFullScreenPortraitUp)
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expand Down Expand Up @@ -855,7 +857,7 @@ class MobileVideoPlayerState extends State<MobileVideoPlayer>
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
if (_isFullScreen)
if (_isFullScreen && !_isFullScreenPortraitUp)
IconButton(
color: Colors.white,
iconSize: 30,
Expand All @@ -877,7 +879,7 @@ class MobileVideoPlayerState extends State<MobileVideoPlayer>
onPressed: _switchPlayerPauseOrPlay,
),
const SizedBox(width: 20),
if (_isFullScreen)
if (_isFullScreen && !_isFullScreenPortraitUp)
IconButton(
color: Colors.white,
iconSize: 30,
Expand All @@ -896,7 +898,7 @@ class MobileVideoPlayerState extends State<MobileVideoPlayer>
crossAxisAlignment: CrossAxisAlignment.end,
children: [
// 倍速按钮
if (_isFullScreen)
if (_isFullScreen && !_isFullScreenPortraitUp)
IconButton(
iconSize: 24,
color: Colors.white,
Expand Down Expand Up @@ -938,6 +940,23 @@ class MobileVideoPlayerState extends State<MobileVideoPlayer>
onPressed: _getSubtitleTracks,
),

if(_isFullScreen)
IconButton(onPressed: ()async {
if (_isFullScreenPortraitUp) {
await SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeRight,
DeviceOrientation.landscapeLeft,
]);
_isFullScreenPortraitUp = false;
} else {
await SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp
]);
_isFullScreenPortraitUp = true;
}

}, icon: const Icon(Icons.screen_rotation_alt, color: Colors.white,)),

// 全屏控制按钮
IconButton(
iconSize: 24,
Expand Down

0 comments on commit a8a692e

Please sign in to comment.