11import 'dart:async' ;
2- import 'dart:ui' as ui;
32
43import 'package:flutter/services.dart' ;
54import 'package:stream_thumbnail/stream_thumbnail.dart' ;
6- import 'package:thumblr/thumblr.dart' as thumblr;
7-
8- import '../../stream_chat_flutter.dart' ;
9- import '../utils/device_segmentation.dart' ;
105
116///
127// ignore: prefer-match-file-name
@@ -18,20 +13,18 @@ class _IVideoService {
1813
1914 /// Generates a thumbnail image data in memory as UInt8List.
2015 ///
21- /// The video source can be a local video file or a URL.
22- ///
23- /// Thumbnails are not supported on Web at this time.
16+ /// The video source can be a local video file or a URL, on every platform.
2417 ///
2518 /// If no [video] path is supplied, or if a thumbnail cannot be generated,
2619 /// returns [generatePlaceholderThumbnail] . A stock placeholder image.
2720 ///
28- /// For desktop, you can specify the position of the video to generate
29- /// the thumbnail.
21+ /// Use [timeMs] to pick the frame, and [maxHeight] /[maxWidth] to bound the
22+ /// size or `0` to keep the source resolution. A lower [quality] reduces
23+ /// image quality, but it gets ignored for PNG format.
3024 ///
31- /// For mobile, you can specify the maximum height or width for the thumbnail
32- /// or 0 for same resolution as the original video. The lower quality value
33- /// creates lower quality of the thumbnail image, but it gets ignored for
34- /// PNG format.
25+ /// [headers] are sent when fetching a remote video, except on Windows, which
26+ /// cannot attach them. Windows also has no WebP encoder, so
27+ /// [StreamThumbnailFormat.webp] fails there.
3528 Future <Uint8List ?> generateVideoThumbnail ({
3629 String ? video,
3730 Map <String , String >? headers,
@@ -45,22 +38,6 @@ class _IVideoService {
4538 if (video == null ) return generatePlaceholderThumbnail ();
4639
4740 try {
48- // If the device is a desktop, use thumblr to generate the thumbnail.
49- if (isDesktopDevice) {
50- final thumbnail = await thumblr.generateThumbnail (filePath: video);
51- final byteData = await thumbnail.image.toByteData (
52- format: ui.ImageByteFormat .png,
53- );
54-
55- final bytesList = byteData? .buffer.asUint8List ();
56- if (bytesList != null && bytesList.isNotEmpty) {
57- return bytesList;
58- }
59-
60- return await generatePlaceholderThumbnail ();
61- }
62-
63- // Otherwise, use the stream_thumbnail plugin to generate the thumbnail.
6441 return await StreamThumbnail .thumbnailData (
6542 video: video,
6643 headers: headers,
0 commit comments