chore: Follow up videoplayer

Signed-off-by: Christian Kußowski <c.kussowski@famedly.com>
pull/1859/head
Christian Kußowski 5 months ago
parent 55705d761d
commit f3c36e0b09
No known key found for this signature in database
GPG Key ID: E067ECD60F1A0652

@ -68,6 +68,8 @@ class EventVideoPlayer extends StatelessWidget {
child: SizedBox( child: SizedBox(
width: width, width: width,
height: height, height: height,
child: Hero(
tag: event.eventId,
child: Stack( child: Stack(
children: [ children: [
if (event.hasThumbnail) if (event.hasThumbnail)
@ -115,6 +117,7 @@ class EventVideoPlayer extends StatelessWidget {
), ),
), ),
), ),
),
if (fileDescription != null && textColor != null && linkColor != null) if (fileDescription != null && textColor != null && linkColor != null)
SizedBox( SizedBox(
width: width, width: width,

@ -70,6 +70,7 @@ class EventVideoPlayerState extends State<EventVideoPlayer> {
await videoPlayerController.initialize(); await videoPlayerController.initialize();
// Create a ChewieController on top. // Create a ChewieController on top.
setState(() {
_chewieController = ChewieController( _chewieController = ChewieController(
videoPlayerController: videoPlayerController, videoPlayerController: videoPlayerController,
useRootNavigator: !kIsWeb, useRootNavigator: !kIsWeb,
@ -77,6 +78,7 @@ class EventVideoPlayerState extends State<EventVideoPlayer> {
autoInitialize: true, autoInitialize: true,
looping: true, looping: true,
); );
});
} on IOException catch (e) { } on IOException catch (e) {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( SnackBar(
@ -117,32 +119,45 @@ class EventVideoPlayerState extends State<EventVideoPlayer> {
final blurHash = (widget.event.infoMap as Map<String, dynamic>) final blurHash = (widget.event.infoMap as Map<String, dynamic>)
.tryGet<String>('xyz.amorgan.blurhash') ?? .tryGet<String>('xyz.amorgan.blurhash') ??
fallbackBlurHash; fallbackBlurHash;
final infoMap = widget.event.content.tryGetMap<String, Object?>('info');
const width = 300.0; final videoWidth = infoMap?.tryGet<int>('w') ?? 400;
final videoHeight = infoMap?.tryGet<int>('h') ?? 300;
final height = MediaQuery.of(context).size.height - 52;
final width = videoWidth * (height / videoHeight);
final chewieController = _chewieController; final chewieController = _chewieController;
return chewieController != null return chewieController != null
? Center(child: Chewie(controller: chewieController)) ? Center(
child: SizedBox(
width: width,
height: height,
child: Chewie(controller: chewieController),
),
)
: Stack( : Stack(
children: [ children: [
Center( Center(
child: Hero(
tag: widget.event.eventId,
child: hasThumbnail child: hasThumbnail
? MxcImage( ? MxcImage(
event: widget.event, event: widget.event,
isThumbnail: true, isThumbnail: true,
width: width, width: width,
height: height,
fit: BoxFit.cover, fit: BoxFit.cover,
placeholder: (context) => BlurHash( placeholder: (context) => BlurHash(
blurhash: blurHash, blurhash: blurHash,
width: width, width: width,
height: width, height: height,
fit: BoxFit.cover, fit: BoxFit.cover,
), ),
) )
: BlurHash( : BlurHash(
blurhash: blurHash, blurhash: blurHash,
width: width, width: width,
height: width, height: height,
),
), ),
), ),
const Center(child: CircularProgressIndicator.adaptive()), const Center(child: CircularProgressIndicator.adaptive()),

Loading…
Cancel
Save