diff --git a/lib/pages/live/widgets/live_item.dart b/lib/pages/live/widgets/live_item.dart index 4768a4eb..af8f9f18 100644 --- a/lib/pages/live/widgets/live_item.dart +++ b/lib/pages/live/widgets/live_item.dart @@ -90,7 +90,7 @@ class LiveContent extends StatelessWidget { return Expanded( child: Padding( // 多列 - padding: const EdgeInsets.fromLTRB(8, 8, 6, 4), + padding: const EdgeInsets.fromLTRB(8, 7, 6, 4), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ diff --git a/lib/pages/liveRoom/controller.dart b/lib/pages/liveRoom/controller.dart index b910bc6e..42e28e10 100644 --- a/lib/pages/liveRoom/controller.dart +++ b/lib/pages/liveRoom/controller.dart @@ -10,11 +10,14 @@ class LiveRoomController extends GetxController { late int roomId; var liveItem; late String heroTag; + double volume = 0.0; + // 静音状态 + RxBool volumeOff = false.obs; MeeduPlayerController meeduPlayerController = MeeduPlayerController( colorTheme: Theme.of(Get.context!).colorScheme.primary, pipEnabled: true, - controlsStyle: ControlsStyle.youtube, + controlsStyle: ControlsStyle.live, enabledButtons: const EnabledButtons(pip: true), ); @@ -45,6 +48,7 @@ class LiveRoomController extends GetxController { ), autoplay: true, ); + volume = meeduPlayerController.volume.value; } Future queryLiveInfo() async { @@ -59,4 +63,18 @@ class LiveRoomController extends GetxController { playerInit(videoUrl); } } + + void setVolumn(value) { + if (value == 0) { + // 设置音量 + volumeOff.value = false; + meeduPlayerController.setVolume(volume); + } else { + // 取消音量 + volume = value; + volumeOff.value = true; + meeduPlayerController.setVolume(0); + } + print('🌹:${volumeOff.value}'); + } } diff --git a/lib/pages/liveRoom/view.dart b/lib/pages/liveRoom/view.dart index 556803e5..73718eca 100644 --- a/lib/pages/liveRoom/view.dart +++ b/lib/pages/liveRoom/view.dart @@ -69,13 +69,20 @@ class _LiveRoomPageState extends State { _liveRoomController.liveItem.uname, style: const TextStyle(fontSize: 14), ), - const SizedBox(height: 3), - Text(_liveRoomController.liveItem.title, + const SizedBox(height: 1), + Text(_liveRoomController.liveItem.watchedShow['text_large'], style: const TextStyle(fontSize: 12)), ], - ) + ), ], ), + actions: [ + SizedBox( + height: 34, + child: ElevatedButton(onPressed: () {}, child: const Text('关注')), + ), + const SizedBox(width: 12), + ], ), body: Column( children: [ @@ -86,6 +93,36 @@ class _LiveRoomPageState extends State { AspectRatio( aspectRatio: 16 / 9, child: MeeduVideoPlayer( + header: (BuildContext context, + MeeduPlayerController _meeduPlayerController, + 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!, ), ), @@ -110,9 +147,6 @@ class _LiveRoomPageState extends State { Container( height: 45, padding: const EdgeInsets.only(left: 12, right: 12), - child: Row(children: [ - Text(_liveRoomController.liveItem.watchedShow['text_large']), - ]), decoration: BoxDecoration( color: Theme.of(context).colorScheme.background, border: Border( @@ -120,6 +154,56 @@ class _LiveRoomPageState extends State { color: Theme.of(context).dividerColor.withOpacity(0.1)), ), ), + child: Row(children: [ + // 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: () => _liveRoomController + .setVolumn(_meeduPlayerController!.volume.value), + icon: Obx(() => Icon( + _liveRoomController.volumeOff.value + ? Icons.volume_off_outlined + : Icons.volume_up_outlined, + size: 21, + )), + ), + ), + SizedBox( + width: 38, + height: 38, + child: IconButton( + onPressed: () => + _meeduPlayerController!.goToFullscreen(context), + icon: const Icon( + Icons.fullscreen, + ), + ), + ), + ]), ), ], ), diff --git a/pubspec.lock b/pubspec.lock index dc53572e..c8fa36f7 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -424,7 +424,7 @@ packages: description: path: package ref: feature-custom - resolved-ref: ea73de29401ab35126ef3eac68270b2e6c3ef4e0 + resolved-ref: "3b879c2ea736ade61236f82d5009230e054db5dd" url: "https://github.com/guozhigq/flutter_meedu_media_kit.git" source: git version: "4.2.12"