Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,12 @@ command:
streaming_shared_preferences: ^2.0.0
svg_icon_widget: ^0.0.1
stream_core_flutter: ^0.5.1
stream_thumbnail: ^0.1.0
stream_thumbnail:
git:
url: https://github.com/GetStream/stream-core-flutter.git
ref: 2aea1413997af886ee951921d71e6b8cb8c5cfbb
path: packages/stream_thumbnail
synchronized: ^3.4.0
thumblr: ^0.0.4
url_launcher: ^6.3.2
uuid: ^4.5.3
video_player: ^2.11.1
Expand Down
9 changes: 9 additions & 0 deletions packages/stream_chat_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
## Upcoming

⚠️ Changed

- Video thumbnails now use `stream_thumbnail` on every platform, and the `thumblr`
dependency is gone. Desktop can now thumbnail remote video URLs, including
authenticated ones.
- Linux builds now need the FFmpeg and libwebp development packages — on Debian/Ubuntu:
`libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libwebp-dev`.
- On Windows, `headers` are not sent, so an authenticated video URL will not resolve.

🐞 Fixed

- Fixed `StreamAttachmentHandler` throwing `UnimplementedError` on WebAssembly builds.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
file_selector_linux
record_linux
sqlite3_flutter_libs
stream_thumbnail
url_launcher_linux
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
record_windows
share_plus
sqlite3_flutter_libs
thumblr_windows
stream_thumbnail
url_launcher_windows
)

Expand Down
37 changes: 7 additions & 30 deletions packages/stream_chat_flutter/lib/src/video/video_service.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import 'dart:async';
import 'dart:ui' as ui;

import 'package:flutter/services.dart';
import 'package:stream_thumbnail/stream_thumbnail.dart';
import 'package:thumblr/thumblr.dart' as thumblr;

import '../../stream_chat_flutter.dart';
import '../utils/device_segmentation.dart';

///
// ignore: prefer-match-file-name
Expand All @@ -18,20 +13,18 @@ class _IVideoService {

/// Generates a thumbnail image data in memory as UInt8List.
///
/// The video source can be a local video file or a URL.
///
/// Thumbnails are not supported on Web at this time.
/// The video source can be a local video file or a URL, on every platform.
///
/// If no [video] path is supplied, or if a thumbnail cannot be generated,
/// returns [generatePlaceholderThumbnail]. A stock placeholder image.
///
/// For desktop, you can specify the position of the video to generate
/// the thumbnail.
/// Use [timeMs] to pick the frame, and [maxHeight]/[maxWidth] to bound the
/// size or `0` to keep the source resolution. A lower [quality] reduces
/// image quality, but it gets ignored for PNG format.
///
/// For mobile, you can specify the maximum height or width for the thumbnail
/// or 0 for same resolution as the original video. The lower quality value
/// creates lower quality of the thumbnail image, but it gets ignored for
/// PNG format.
/// [headers] are sent when fetching a remote video, except on Windows, which
/// cannot attach them. Windows also has no WebP encoder, so
/// [StreamThumbnailFormat.webp] fails there.
Future<Uint8List?> generateVideoThumbnail({
String? video,
Map<String, String>? headers,
Expand All @@ -45,22 +38,6 @@ class _IVideoService {
if (video == null) return generatePlaceholderThumbnail();

try {
// If the device is a desktop, use thumblr to generate the thumbnail.
if (isDesktopDevice) {
final thumbnail = await thumblr.generateThumbnail(filePath: video);
final byteData = await thumbnail.image.toByteData(
format: ui.ImageByteFormat.png,
);

final bytesList = byteData?.buffer.asUint8List();
if (bytesList != null && bytesList.isNotEmpty) {
return bytesList;
}

return await generatePlaceholderThumbnail();
}

// Otherwise, use the stream_thumbnail plugin to generate the thumbnail.
return await StreamThumbnail.thumbnailData(
video: video,
headers: headers,
Expand Down
15 changes: 13 additions & 2 deletions packages/stream_chat_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,22 @@ dependencies:
shimmer: ^3.0.0
stream_chat_flutter_core: ^10.4.0
stream_core_flutter: ^0.5.1
stream_thumbnail: ^0.1.0
stream_thumbnail:
# The ignore below silences `invalid_dependency` because we occasionally
# pin stream_thumbnail to a git ref to iterate on it alongside this
# SDK between its releases.
#
# **Note:** Before publishing stream_chat_flutter, this MUST be swapped
# back to a pub version constraint — git deps are not allowed on pub.dev
# and will block the release.
# ignore: invalid_dependency
git:
url: https://github.com/GetStream/stream-core-flutter.git
ref: 2aea1413997af886ee951921d71e6b8cb8c5cfbb
path: packages/stream_thumbnail
svg_icon_widget: ^0.0.1
synchronized: ^3.4.0
theme_extensions_builder_annotation: ^7.1.0
thumblr: ^0.0.4
url_launcher: ^6.3.2
video_player: ^2.11.1

Expand Down
Loading