Skip to content

Commit

Permalink
Merge pull request #614 from lamarios/feature/remove-audio-only-switc…
Browse files Browse the repository at this point in the history
…h-for-live-streams

remove audio switch for live videos
  • Loading branch information
lamarios authored Oct 5, 2024
2 parents 69e2964 + a8e1d8b commit 7f5b252
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 18 deletions.
7 changes: 6 additions & 1 deletion lib/player/views/components/mini_player_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,17 @@ class MiniPlayerControls extends StatelessWidget {
var cubit = context.read<SettingsCubit>();
var isAudio = context
.select((PlayerCubit value) => value.state.isAudio);

var hasAudio = context.select((PlayerCubit value) =>
!(value.state.currentlyPlaying?.liveNow ?? false));

return Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Visibility(
// only for online videos
visible: player.state.currentlyPlaying != null,
visible:
player.state.currentlyPlaying != null && hasAudio,
child: MultiValueSwitch(
left: Icons.ondemand_video,
right: Icons.audiotrack,
Expand Down
1 change: 1 addition & 0 deletions lib/videos/views/components/inner_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class VideoInnerView extends StatelessWidget {

var playButton = PlayButton(
icon: restart ? Icons.refresh : null,
hasAudio: !(video.liveNow ?? false),
onPressed: restart ? cubit.restartVideo : cubit.playVideo,
);
return Column(
Expand Down
1 change: 1 addition & 0 deletions lib/videos/views/components/inner_view_tablet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class VideoTabletInnerView extends StatelessWidget {
children: [
PlayButton(
icon: restart ? Icons.refresh : null,
hasAudio: !(video.liveNow ?? false),
onPressed:
restart ? cubit.restartVideo : cubit.playVideo,
),
Expand Down
35 changes: 19 additions & 16 deletions lib/videos/views/components/play_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,37 @@ import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';

class PlayButton extends StatelessWidget {
final bool hasAudio;
final Function(bool isAudio) onPressed;
final IconData? icon;

const PlayButton({super.key, required this.onPressed, this.icon});
const PlayButton(
{super.key, required this.onPressed, this.icon, this.hasAudio = true});

@override
Widget build(BuildContext context) {
ColorScheme colorScheme = Theme.of(context).colorScheme;
return Stack(
alignment: Alignment.center,
children: [
Padding(
padding: const EdgeInsets.only(left: 100.0, top: 60),
child: IconButton(
onPressed: () {
onPressed(true);
AutoRouter.of(context).maybePop();
},
style: ButtonStyle(
backgroundColor: WidgetStateProperty.resolveWith(
(states) => colorScheme.primary.withOpacity(1))),
icon: const Icon(
Icons.music_note,
size: 35,
if (hasAudio)
Padding(
padding: const EdgeInsets.only(left: 100.0, top: 60),
child: IconButton(
onPressed: () {
onPressed(true);
AutoRouter.of(context).maybePop();
},
style: ButtonStyle(
backgroundColor: WidgetStateProperty.resolveWith(
(states) => colorScheme.primary.withOpacity(1))),
icon: const Icon(
Icons.music_note,
size: 35,
),
color: colorScheme.primaryContainer,
),
color: colorScheme.primaryContainer,
),
),
IconButton(
onPressed: () {
onPressed(false);
Expand Down
3 changes: 2 additions & 1 deletion lib/videos/views/components/video_metrics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ class VideoMetrics extends StatelessWidget {
}

var date = video?.publishedText ?? '';
if (date.isNotEmpty || video?.liveNow == true) {
if ((date.isNotEmpty && !date.startsWith('0')) ||
video?.liveNow == true) {
metrics.addAll([
(video?.liveNow ?? false)
? Visibility(
Expand Down

0 comments on commit 7f5b252

Please sign in to comment.