Skip to content

Commit

Permalink
Merge pull request #285 from takenet/fix/768386-fix-audio-load
Browse files Browse the repository at this point in the history
#768386 - [Fix]: fix when thumbnail is unavailable
  • Loading branch information
githubdoandre authored Dec 9, 2024
2 parents 5f59cb3 + c6b19a1 commit c9a7ad9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
23 changes: 14 additions & 9 deletions lib/src/controllers/chat/ds_video_message_bubble.controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@ class DSVideoMessageBubbleController {
final int mediaSize;
final Map<String, String?>? httpHeaders;
final String type;

final maximumProgress = RxInt(0);
final downloadProgress = RxInt(0);
final isDownloading = RxBool(false);
final thumbnail = RxString('');
final hasError = RxBool(false);
final isLoadingThumbnail = RxBool(false);
final isThumbnailUnavailable = RxBool(false);

DSVideoMessageBubbleController({
required this.url,
Expand All @@ -29,11 +35,6 @@ class DSVideoMessageBubbleController {
getStoredVideo();
}

final isDownloading = RxBool(false);
final thumbnail = RxString('');
final hasError = RxBool(false);
final isLoadingThumbnail = RxBool(false);

String size() {
return mediaSize > 0
? FileSize.getSize(
Expand Down Expand Up @@ -127,10 +128,14 @@ class DSVideoMessageBubbleController {
Future<void> _generateThumbnail(String path) async {
final thumbnailPath = await getFullThumbnailPath();

await DSMediaFormatService.getVideoThumbnail(
input: path,
output: thumbnailPath,
);
try {
await DSMediaFormatService.getVideoThumbnail(
input: path,
output: thumbnailPath,
);
} catch (e) {
isThumbnailUnavailable.value = true;
}

thumbnail.value = thumbnailPath;
}
Expand Down
27 changes: 17 additions & 10 deletions lib/src/widgets/chat/video/ds_video_message_bubble.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -220,16 +220,23 @@ class _DSVideoMessageBubbleState extends State<DSVideoMessageBubble>
url: widget.url,
shouldAuthenticate:
widget.shouldAuthenticate,
thumbnail: Center(
child: Image.file(
File(
_controller.thumbnail.value,
),
width: DSUtils.bubbleMinSize,
height: DSUtils.bubbleMinSize,
fit: BoxFit.cover,
),
),
thumbnail: _controller
.isThumbnailUnavailable
.value
? const SizedBox.shrink()
: Center(
child: Image.file(
File(
_controller
.thumbnail.value,
),
width: DSUtils
.bubbleMinSize,
height: DSUtils
.bubbleMinSize,
fit: BoxFit.cover,
),
),
),
)
: _buidErrorIcon(),
Expand Down

0 comments on commit c9a7ad9

Please sign in to comment.