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
|
? 1.0
|
||||||
: duration.inMilliseconds.toDouble();
|
: duration.inMilliseconds.toDouble();
|
||||||
|
|
||||||
return Row(
|
final playButton = loading || buffering
|
||||||
children: [
|
? SizedBox.square(
|
||||||
if (loading || buffering)
|
|
||||||
SizedBox.square(
|
|
||||||
dimension: 48,
|
dimension: 48,
|
||||||
child: CircularProgressIndicator(padding: .all(12), color: color),
|
child: CircularProgressIndicator(padding: .all(12), color: color),
|
||||||
)
|
)
|
||||||
else
|
: IconButton(
|
||||||
IconButton(
|
|
||||||
onPressed: player.playOrPause,
|
onPressed: player.playOrPause,
|
||||||
color: color,
|
color: color,
|
||||||
tooltip: playing ? "Pause" : "Play",
|
tooltip: playing ? "Pause" : "Play",
|
||||||
icon: Icon(playing ? Icons.pause_circle : Icons.play_circle),
|
icon: Icon(playing ? Icons.pause_circle : Icons.play_circle),
|
||||||
),
|
);
|
||||||
SizedBox(width: 8),
|
|
||||||
Text(format(position), style: textStyle),
|
Slider slider({EdgeInsetsGeometry? padding}) => Slider(
|
||||||
Expanded(
|
padding: padding,
|
||||||
child: Slider(
|
|
||||||
max: max,
|
max: max,
|
||||||
value: min(position.inMilliseconds.toDouble(), max),
|
value: min(position.inMilliseconds.toDouble(), max),
|
||||||
onChanged: loading
|
onChanged: loading
|
||||||
? null
|
? null
|
||||||
: (value) => player.seek(.new(milliseconds: value.toInt())),
|
: (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),
|
Text(format(duration), style: textStyle),
|
||||||
...actions,
|
...actions,
|
||||||
],
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue