flutter video_thumbnail #获取视频封面

List<Image> imageList = List<Image>();

把获取的图片uint8list封装成image 

    final thumbnail = await VideoThumbnail.thumbnailFile(
        video: element,
        thumbnailPath: _tempDir,
        imageFormat: _format,
        maxHeightOrWidth: 100,
        quality: 50);

    print("thumbnail file is located: $thumbnail");

    final file = File(thumbnail);
    _imageFileSize = file.lengthSync();
    final bytes = file.readAsBytesSync();

    print("image file size: $_imageFileSize");


    _imageInFile = Image.memory(bytes,fit: BoxFit.cover)
      ..image
          .resolve(new ImageConfiguration())
          .addListener(ImageStreamListener((ImageInfo info, bool _) {}));

  }else{
    _imageInFile= new Image.file(File(element), fit: BoxFit.cover);
  }

  setState(() {
    imageList.add(_imageInFile);
  });
});

猜你喜欢

转载自blog.csdn.net/ren1027538427/article/details/122772381
今日推荐