kopia lustrzana https://gitlab.com/mysocialportal/relatica
Add video handling on MediaViewerScreen (but just with a stand-in)
rodzic
e24aceaeeb
commit
47a7c02eb4
|
@ -57,13 +57,13 @@ class _MediaKitAvControlState extends State<MediaKitAvControl> {
|
|||
super.deactivate();
|
||||
}
|
||||
|
||||
void toggleVideoPlay() async {
|
||||
Future<void> toggleVideoPlay() async {
|
||||
_logger.fine('Toggling play on: ${widget.videoUrl}');
|
||||
if (needToOpen) {
|
||||
await player.open(Media(widget.videoUrl), play: false);
|
||||
needToOpen = false;
|
||||
}
|
||||
player.playOrPause();
|
||||
await player.playOrPause();
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
|
@ -81,6 +81,7 @@ class _MediaKitAvControlState extends State<MediaKitAvControl> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print('Building MediaKit Control');
|
||||
final playing = player.state.playing;
|
||||
if (controller == null) {
|
||||
return Container(
|
||||
width: widget.width,
|
||||
|
@ -111,7 +112,7 @@ class _MediaKitAvControlState extends State<MediaKitAvControl> {
|
|||
Row(
|
||||
children: [
|
||||
IconButton(
|
||||
icon: player.state.playing
|
||||
icon: playing
|
||||
? const Icon(Icons.pause)
|
||||
: const Icon(Icons.play_arrow),
|
||||
onPressed: toggleVideoPlay,
|
||||
|
|
|
@ -9,6 +9,7 @@ import 'package:path_provider/path_provider.dart';
|
|||
import '../controls/login_aware_cached_network_image.dart';
|
||||
import '../friendica_client/friendica_client.dart';
|
||||
import '../globals.dart';
|
||||
import '../models/attachment_media_type_enum.dart';
|
||||
import '../models/media_attachment.dart';
|
||||
import '../services/auth_service.dart';
|
||||
import '../utils/clipboard_utils.dart';
|
||||
|
@ -98,12 +99,37 @@ class _MediaViewerScreenState extends State<MediaViewerScreen> {
|
|||
final descriptionHeightPct = widget.attachments.isEmpty ? 0.0 : 0.1;
|
||||
final mediaHeight = height * (1 - descriptionHeightPct);
|
||||
final descriptionHeight = height * descriptionHeightPct;
|
||||
|
||||
late final bool canSave;
|
||||
late final Widget mediaViewer;
|
||||
switch (currentAttachment.explicitType) {
|
||||
case AttachmentMediaType.image:
|
||||
canSave = true;
|
||||
mediaViewer = SizedBox(
|
||||
width: width,
|
||||
height: mediaHeight,
|
||||
child: InteractiveViewer(
|
||||
maxScale: 10.0,
|
||||
scaleFactor: 400,
|
||||
child: LoginAwareCachedNetworkImage(
|
||||
imageUrl: currentAttachment.uri.toString()),
|
||||
));
|
||||
break;
|
||||
case AttachmentMediaType.unknown:
|
||||
case AttachmentMediaType.video:
|
||||
canSave = false;
|
||||
mediaViewer = Text(
|
||||
'No media viewer for ${currentAttachment.explicitType.name} type for link ${currentAttachment.fullFileUri}');
|
||||
break;
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () => saveImage(context, currentAttachment),
|
||||
icon: const Icon(Icons.download))
|
||||
if (canSave)
|
||||
IconButton(
|
||||
onPressed: () => saveImage(context, currentAttachment),
|
||||
icon: const Icon(Icons.download))
|
||||
],
|
||||
),
|
||||
body: SafeArea(
|
||||
|
@ -112,16 +138,7 @@ class _MediaViewerScreenState extends State<MediaViewerScreen> {
|
|||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: width,
|
||||
height: mediaHeight,
|
||||
child: InteractiveViewer(
|
||||
maxScale: 10.0,
|
||||
scaleFactor: 400,
|
||||
child: LoginAwareCachedNetworkImage(
|
||||
imageUrl: currentAttachment.uri.toString()),
|
||||
),
|
||||
),
|
||||
mediaViewer,
|
||||
if (currentAttachment.description.isNotEmpty)
|
||||
buildTextArea(currentAttachment, descriptionHeight),
|
||||
],
|
||||
|
|
Ładowanie…
Reference in New Issue