@@ -458,129 +458,130 @@ class LocalState extends State<Local> {
458458 Navigator .pop (context);
459459 // Uncomment to use picker instead of hardcoding the video url
460460
461- final picker = ImagePicker ();
462- final result = await picker.pickVideo (
463- source: ImageSource .gallery,
464- );
461+ // final picker = ImagePicker();
462+ // final result = await picker.pickVideo(
463+ // source: ImageSource.gallery,
464+ // );
465465
466- if (result != null ) {
467- String ? thumbHash;
468- int ? width;
469- int ? height;
470- int ? fileSizeInBytes;
471- try {
472- // Optionally get the file size
473- fileSizeInBytes = await result.length ();
474-
475- // Get the video width and height
476- final fullSizeimageBytes =
477- await VideoThumbnail .thumbnailData (
478- video: result.path,
479- imageFormat: ImageFormat .WEBP ,
480- quality: 1 ,
481- );
482-
483- final fullSizedecoded = img.decodeImage (
484- fullSizeimageBytes! ,
485- );
486- if (fullSizedecoded != null ) {
487- width = fullSizedecoded.width;
488- height = fullSizedecoded.height;
489- }
490-
491- // Generate the thumbhash
492- final thumbSizeImageBytes =
493- await VideoThumbnail .thumbnailData (
494- video: result.path,
495- imageFormat: ImageFormat .WEBP ,
496- maxWidth: 100 ,
497- maxHeight: 100 ,
498- quality: 25 ,
499- );
500- final decoded = img.decodeImage (thumbSizeImageBytes! );
501- if (decoded != null ) {
502- final thumbHashBytes = rgbaToThumbHash (
503- decoded.width,
504- decoded.height,
505- decoded.getBytes (),
506- );
466+ // if (result != null) {
467+ // String? thumbHash;
468+ // int? width;
469+ // int? height;
470+ // int? fileSizeInBytes;
471+ // try {
472+ // // Optionally get the file size
473+ // fileSizeInBytes = await result.length();
474+
475+ // // Get the video width and height
476+ // final fullSizeimageBytes =
477+ // await VideoThumbnail.thumbnailData(
478+ // video: result.path,
479+ // imageFormat: ImageFormat.WEBP,
480+ // quality: 1,
481+ // );
482+
483+ // final fullSizedecoded = img.decodeImage(
484+ // fullSizeimageBytes!,
485+ // );
486+ // if (fullSizedecoded != null) {
487+ // width = fullSizedecoded.width;
488+ // height = fullSizedecoded.height;
489+ // }
490+
491+ // // Generate the thumbhash
492+ // final thumbSizeImageBytes =
493+ // await VideoThumbnail.thumbnailData(
494+ // video: result.path,
495+ // imageFormat: ImageFormat.WEBP,
496+ // maxWidth: 100,
497+ // maxHeight: 100,
498+ // quality: 25,
499+ // );
500+ // final decoded = img.decodeImage(thumbSizeImageBytes!);
501+ // if (decoded != null) {
502+ // final thumbHashBytes = rgbaToThumbHash(
503+ // decoded.width,
504+ // decoded.height,
505+ // decoded.getBytes(),
506+ // );
507507
508- thumbHash = base64.encode (thumbHashBytes);
509- }
510- } catch (e) {
511- debugPrint (e.toString ());
512- }
508+ // thumbHash = base64.encode(thumbHashBytes);
509+ // }
510+ // } catch (e) {
511+ // debugPrint(e.toString());
512+ // }
513513
514- // Create a proper file message
515- final videoMessage = VideoMessage (
516- id: _uuid.v4 (),
517- authorId: _currentUser.id,
518- createdAt: DateTime .now ().toUtc (),
519- sentAt: DateTime .now ().toUtc (),
520- source: result.path,
521- thumbhash: thumbHash,
522- width: width? .toDouble (),
523- height: height? .toDouble (),
524- size: fileSizeInBytes,
525- );
526- await _chatController.insertMessage (videoMessage);
527- }
514+ // // Create a proper file message
515+ // final videoMessage = VideoMessage(
516+ // id: _uuid.v4(),
517+ // authorId: _currentUser.id,
518+ // createdAt: DateTime.now().toUtc(),
519+ // sentAt: DateTime.now().toUtc(),
520+ // source: result.path,
521+ // thumbhash: thumbHash,
522+ // width: width?.toDouble(),
523+ // height: height?.toDouble(),
524+ // size: fileSizeInBytes,
525+ // );
526+ // await _chatController.insertMessage(videoMessage);
527+ // }
528528
529- // const videoUrl =
530- // 'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4';
531- // String? thumbHash;
532- // int? width;
533- // int? height;
534- // try {
535- // // Get the video width and height
536- // final fullSizeimageBytes =
537- // await VideoThumbnail.thumbnailData(
538- // video: videoUrl,
539- // imageFormat: ImageFormat.WEBP,
540- // quality: 1,
541- // );
529+ const videoUrl =
530+ 'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4' ;
531+ String ? thumbHash;
532+ int ? width;
533+ int ? height;
534+ try {
535+ // Get the video width and height
536+ // iOS/ Android ONLY
537+ final fullSizeimageBytes =
538+ await VideoThumbnail .thumbnailData (
539+ video: videoUrl,
540+ imageFormat: ImageFormat .WEBP ,
541+ quality: 1 ,
542+ );
542543
543- // final fullSizedecoded = img.decodeImage(
544- // fullSizeimageBytes!,
545- // );
546- // if (fullSizedecoded != null) {
547- // width = fullSizedecoded.width;
548- // height = fullSizedecoded.height;
549- // }
544+ final fullSizedecoded = img.decodeImage (
545+ fullSizeimageBytes! ,
546+ );
547+ if (fullSizedecoded != null ) {
548+ width = fullSizedecoded.width;
549+ height = fullSizedecoded.height;
550+ }
550551
551- // // Generate the thumbhash
552- // final thumbSizeImageBytes =
553- // await VideoThumbnail.thumbnailData(
554- // video: videoUrl,
555- // imageFormat: ImageFormat.WEBP,
556- // maxWidth: 100,
557- // maxHeight: 100,
558- // quality: 25,
559- // );
560- // final decoded = img.decodeImage(thumbSizeImageBytes!);
561- // if (decoded != null) {
562- // final thumbHashBytes = rgbaToThumbHash(
563- // decoded.width,
564- // decoded.height,
565- // decoded.getBytes(),
566- // );
552+ // Generate the thumbhash
553+ final thumbSizeImageBytes =
554+ await VideoThumbnail .thumbnailData (
555+ video: videoUrl,
556+ imageFormat: ImageFormat .WEBP ,
557+ maxWidth: 100 ,
558+ maxHeight: 100 ,
559+ quality: 25 ,
560+ );
561+ final decoded = img.decodeImage (thumbSizeImageBytes! );
562+ if (decoded != null ) {
563+ final thumbHashBytes = rgbaToThumbHash (
564+ decoded.width,
565+ decoded.height,
566+ decoded.getBytes (),
567+ );
567568
568- // thumbHash = base64.encode(thumbHashBytes);
569- // }
570- // } catch (e) {
571- // debugPrint(e.toString());
572- // }
569+ thumbHash = base64.encode (thumbHashBytes);
570+ }
571+ } catch (e) {
572+ debugPrint (e.toString ());
573+ }
573574
574- // final videoMessage = VideoMessage(
575- // id: _uuid.v4(),
576- // authorId: _currentUser.id,
577- // createdAt: DateTime.now().toUtc(),
578- // source: videoUrl,
579- // thumbhash: thumbHash,
580- // width: width?.toDouble(),
581- // height: height?.toDouble(),
582- // );
583- // await _chatController.insertMessage(videoMessage);
575+ final videoMessage = VideoMessage (
576+ id: _uuid.v4 (),
577+ authorId: _currentUser.id,
578+ createdAt: DateTime .now ().toUtc (),
579+ source: videoUrl,
580+ thumbhash: thumbHash,
581+ width: width? .toDouble (),
582+ height: height? .toDouble (),
583+ );
584+ await _chatController.insertMessage (videoMessage);
584585 },
585586 ),
586587 ],
0 commit comments