fixup controls on narrow videos
This commit is contained in:
parent
9cd43f4e3c
commit
fb0af571ed
1 changed files with 46 additions and 21 deletions
|
|
@ -51,34 +51,59 @@ class const PlayerControls(
|
|||
? 1.0
|
||||
: duration.inMilliseconds.toDouble();
|
||||
|
||||
return Row(
|
||||
children: [
|
||||
if (loading || buffering)
|
||||
SizedBox.square(
|
||||
final playButton = loading || buffering
|
||||
? SizedBox.square(
|
||||
dimension: 48,
|
||||
child: CircularProgressIndicator(padding: .all(12), color: color),
|
||||
)
|
||||
else
|
||||
IconButton(
|
||||
: IconButton(
|
||||
onPressed: player.playOrPause,
|
||||
color: color,
|
||||
tooltip: playing ? "Pause" : "Play",
|
||||
icon: Icon(playing ? Icons.pause_circle : Icons.play_circle),
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Text(format(position), style: textStyle),
|
||||
Expanded(
|
||||
child: Slider(
|
||||
max: max,
|
||||
value: min(position.inMilliseconds.toDouble(), max),
|
||||
onChanged: loading
|
||||
? null
|
||||
: (value) => player.seek(.new(milliseconds: value.toInt())),
|
||||
),
|
||||
),
|
||||
Text(format(duration), style: textStyle),
|
||||
...actions,
|
||||
],
|
||||
);
|
||||
|
||||
Slider slider({EdgeInsetsGeometry? padding}) => Slider(
|
||||
padding: padding,
|
||||
max: max,
|
||||
value: min(position.inMilliseconds.toDouble(), max),
|
||||
onChanged: loading
|
||||
? null
|
||||
: (value) => player.seek(.new(milliseconds: value.toInt())),
|
||||
);
|
||||
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) => constraints.maxWidth < 300
|
||||
? Column(
|
||||
mainAxisSize: .min,
|
||||
children: [
|
||||
slider(padding: const .symmetric(horizontal: 12)),
|
||||
Row(
|
||||
children: [
|
||||
playButton,
|
||||
Expanded(
|
||||
child: Text(
|
||||
"${format(position)} / ${format(duration)}",
|
||||
style: textStyle,
|
||||
maxLines: 1,
|
||||
overflow: .ellipsis,
|
||||
),
|
||||
),
|
||||
...actions,
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
: Row(
|
||||
children: [
|
||||
playButton,
|
||||
SizedBox(width: 8),
|
||||
Text(format(position), style: textStyle),
|
||||
Expanded(child: slider()),
|
||||
Text(format(duration), style: textStyle),
|
||||
...actions,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue