mod: 视频播放器重构 - 基本功能

This commit is contained in:
guozhigq
2023-07-30 22:44:18 +08:00
parent ca12be5373
commit 636ff2b9ad
31 changed files with 1583 additions and 390 deletions

View File

@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_meedu_media_kit/meedu_player.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/plugin/pl_player/index.dart';
import 'controller.dart';
@ -14,7 +14,7 @@ class LiveRoomPage extends StatefulWidget {
class _LiveRoomPageState extends State<LiveRoomPage> {
final LiveRoomController _liveRoomController = Get.put(LiveRoomController());
MeeduPlayerController? _meeduPlayerController;
PlPlayerController? plPlayerController;
bool isShowCover = true;
bool isPlay = true;
@ -22,8 +22,8 @@ class _LiveRoomPageState extends State<LiveRoomPage> {
@override
void initState() {
super.initState();
_meeduPlayerController = _liveRoomController.meeduPlayerController;
_meeduPlayerController!.onPlayerStatusChanged.listen(
plPlayerController = _liveRoomController.plPlayerController;
plPlayerController!.onPlayerStatusChanged.listen(
(PlayerStatus status) {
if (status == PlayerStatus.playing) {
isShowCover = false;
@ -35,7 +35,7 @@ class _LiveRoomPageState extends State<LiveRoomPage> {
@override
void dispose() {
_meeduPlayerController!.dispose();
plPlayerController!.dispose();
super.dispose();
}
@ -85,62 +85,33 @@ class _LiveRoomPageState extends State<LiveRoomPage> {
body: Column(
children: [
Hero(
tag: _liveRoomController.heroTag,
child: Stack(
children: [
AspectRatio(
aspectRatio: 16 / 9,
child: MeeduVideoPlayer(
header: (BuildContext context,
MeeduPlayerController meeduPlayerController,
Responsive responsive) {
return AppBar(
backgroundColor: Colors.transparent,
primary: false,
elevation: 0,
scrolledUnderElevation: 0,
foregroundColor: Colors.white,
automaticallyImplyLeading: false,
centerTitle: false,
title: Text(_liveRoomController.liveItem.title,
style: const TextStyle(fontSize: 12)),
actions: [
SizedBox(
width: 38,
height: 38,
child: IconButton(
onPressed: () =>
meeduPlayerController.enterPip(context),
icon: const Icon(
Icons.branding_watermark_outlined,
size: 19,
),
),
),
const SizedBox(width: 12)
],
);
},
controller: _meeduPlayerController!,
),
),
if (_liveRoomController.liveItem.cover != null)
Visibility(
visible: isShowCover,
child: Positioned(
top: 0,
left: 0,
right: 0,
child: NetworkImgLayer(
type: 'emote',
src: _liveRoomController.liveItem.cover,
width: Get.size.width,
height: videoHeight,
),
tag: _liveRoomController.heroTag,
child: Stack(
children: [
AspectRatio(
aspectRatio: 16 / 9,
child: plPlayerController!.videoPlayerController != null
? PLVideoPlayer(controller: plPlayerController!)
: const SizedBox(),
),
if (_liveRoomController.liveItem.cover != null)
Visibility(
visible: isShowCover,
child: Positioned(
top: 0,
left: 0,
right: 0,
child: NetworkImgLayer(
type: 'emote',
src: _liveRoomController.liveItem.cover,
width: Get.size.width,
height: videoHeight,
),
),
],
)),
),
],
),
),
if (_liveRoomController.liveItem.watchedShow != null)
Container(
height: 45,
@ -153,35 +124,35 @@ class _LiveRoomPageState extends State<LiveRoomPage> {
),
),
child: Row(children: <Widget>[
// SizedBox(
// width: 38,
// height: 38,
// child: IconButton(
// onPressed: () {},
// icon: const Icon(
// Icons.subtitles_outlined,
// size: 21,
// ),
// ),
// ),
SizedBox(
width: 38,
height: 38,
child: IconButton(
onPressed: () {},
icon: const Icon(
Icons.subtitles_outlined,
size: 21,
),
),
),
const Spacer(),
// SizedBox(
// width: 38,
// height: 38,
// child: IconButton(
// onPressed: () {},
// icon: const Icon(
// Icons.hd_outlined,
// size: 20,
// ),
// ),
// ),
SizedBox(
width: 38,
height: 38,
child: IconButton(
onPressed: () {},
icon: const Icon(
Icons.hd_outlined,
size: 20,
),
),
),
SizedBox(
width: 38,
height: 38,
child: IconButton(
onPressed: () => _liveRoomController
.setVolumn(_meeduPlayerController!.volume.value),
.setVolumn(plPlayerController!.volume.value),
icon: Obx(() => Icon(
_liveRoomController.volumeOff.value
? Icons.volume_off_outlined
@ -194,8 +165,8 @@ class _LiveRoomPageState extends State<LiveRoomPage> {
width: 38,
height: 38,
child: IconButton(
onPressed: () =>
_meeduPlayerController!.goToFullscreen(context),
onPressed: () => {},
// plPlayerController!.goToFullscreen(context),
icon: const Icon(
Icons.fullscreen,
),