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();
|
super.deactivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggleVideoPlay() async {
|
Future<void> toggleVideoPlay() async {
|
||||||
_logger.fine('Toggling play on: ${widget.videoUrl}');
|
_logger.fine('Toggling play on: ${widget.videoUrl}');
|
||||||
if (needToOpen) {
|
if (needToOpen) {
|
||||||
await player.open(Media(widget.videoUrl), play: false);
|
await player.open(Media(widget.videoUrl), play: false);
|
||||||
needToOpen = false;
|
needToOpen = false;
|
||||||
}
|
}
|
||||||
player.playOrPause();
|
await player.playOrPause();
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,6 +81,7 @@ class _MediaKitAvControlState extends State<MediaKitAvControl> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
print('Building MediaKit Control');
|
print('Building MediaKit Control');
|
||||||
|
final playing = player.state.playing;
|
||||||
if (controller == null) {
|
if (controller == null) {
|
||||||
return Container(
|
return Container(
|
||||||
width: widget.width,
|
width: widget.width,
|
||||||
|
@ -111,7 +112,7 @@ class _MediaKitAvControlState extends State<MediaKitAvControl> {
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: player.state.playing
|
icon: playing
|
||||||
? const Icon(Icons.pause)
|
? const Icon(Icons.pause)
|
||||||
: const Icon(Icons.play_arrow),
|
: const Icon(Icons.play_arrow),
|
||||||
onPressed: toggleVideoPlay,
|
onPressed: toggleVideoPlay,
|
||||||
|
|
|
@ -9,6 +9,7 @@ import 'package:path_provider/path_provider.dart';
|
||||||
import '../controls/login_aware_cached_network_image.dart';
|
import '../controls/login_aware_cached_network_image.dart';
|
||||||
import '../friendica_client/friendica_client.dart';
|
import '../friendica_client/friendica_client.dart';
|
||||||
import '../globals.dart';
|
import '../globals.dart';
|
||||||
|
import '../models/attachment_media_type_enum.dart';
|
||||||
import '../models/media_attachment.dart';
|
import '../models/media_attachment.dart';
|
||||||
import '../services/auth_service.dart';
|
import '../services/auth_service.dart';
|
||||||
import '../utils/clipboard_utils.dart';
|
import '../utils/clipboard_utils.dart';
|
||||||
|
@ -98,9 +99,34 @@ class _MediaViewerScreenState extends State<MediaViewerScreen> {
|
||||||
final descriptionHeightPct = widget.attachments.isEmpty ? 0.0 : 0.1;
|
final descriptionHeightPct = widget.attachments.isEmpty ? 0.0 : 0.1;
|
||||||
final mediaHeight = height * (1 - descriptionHeightPct);
|
final mediaHeight = height * (1 - descriptionHeightPct);
|
||||||
final descriptionHeight = height * 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(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
actions: [
|
actions: [
|
||||||
|
if (canSave)
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () => saveImage(context, currentAttachment),
|
onPressed: () => saveImage(context, currentAttachment),
|
||||||
icon: const Icon(Icons.download))
|
icon: const Icon(Icons.download))
|
||||||
|
@ -112,16 +138,7 @@ class _MediaViewerScreenState extends State<MediaViewerScreen> {
|
||||||
Column(
|
Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
mediaViewer,
|
||||||
width: width,
|
|
||||||
height: mediaHeight,
|
|
||||||
child: InteractiveViewer(
|
|
||||||
maxScale: 10.0,
|
|
||||||
scaleFactor: 400,
|
|
||||||
child: LoginAwareCachedNetworkImage(
|
|
||||||
imageUrl: currentAttachment.uri.toString()),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (currentAttachment.description.isNotEmpty)
|
if (currentAttachment.description.isNotEmpty)
|
||||||
buildTextArea(currentAttachment, descriptionHeight),
|
buildTextArea(currentAttachment, descriptionHeight),
|
||||||
],
|
],
|
||||||
|
|
Ładowanie…
Reference in New Issue