Skip to content

Commit

Permalink
fix video, gif, mute
Browse files Browse the repository at this point in the history
  • Loading branch information
ppupha committed Oct 23, 2024
1 parent b3c0aa6 commit 5a025d4
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 70 deletions.
16 changes: 9 additions & 7 deletions lib/nft_rendering/gif_rendering_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ class _GifNFTRenderingWidgetState extends State<GifNFTRenderingWidget> {
void initState() {
super.initState();
if (widget.previewURL.isEmpty) {
setState(() {
_isLoading = false;
WidgetsBinding.instance.addPostFrameCallback((_) {
setState(() {
_isLoading = false;
});
});
}
}
Expand Down Expand Up @@ -81,15 +83,15 @@ class _GifNFTRenderingWidgetState extends State<GifNFTRenderingWidget> {

void _onImageLoaded() {
if (_isLoading) {
setState(() {
_isLoading = false;
WidgetsBinding.instance?.addPostFrameCallback((_) {
setState(() {
_isLoading = false;
});
});
widget.onLoaded?.call();
}
}

@override
Widget build(BuildContext context) => _isLoading
? widget.loadingWidget ?? const Center(child: CircularProgressIndicator())
: _buildGifWidget();
Widget build(BuildContext context) => _buildGifWidget();
}
6 changes: 2 additions & 4 deletions lib/nft_rendering/video_player_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,12 @@ class _VideoNFTRenderingWidgetState
return widget.noPreviewUrlWidget; // Show no preview URL widget
}

if (_shouldUseThumbnail && thumbnailURL != null) {
if ((_shouldUseThumbnail || _isPlayingFailed) && thumbnailURL != null) {
return _videoThumbnail(thumbnailURL);
}

if (_controller != null) {
if ((_isPlayingFailed || _shouldUseThumbnail) && thumbnailURL != null) {
return _videoThumbnail(thumbnailURL);
} else if (_isPreviewLoaded) {
if (_isPreviewLoaded) {
return Stack(
children: [
Center(
Expand Down
119 changes: 60 additions & 59 deletions lib/view/feralfile_artwork_preview_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,70 +69,71 @@ class _FeralfileArtworkPreviewWidgetState
return BlocProvider(
create: (_) => RetryCubit(),
child: BlocBuilder<RetryCubit, int>(
builder: (context, attempt) {
return BlocBuilder<FFArtworkPreviewBloc, FFArtworkPreviewState>(
bloc: context.read<FFArtworkPreviewBloc>(),
builder: (context, state) {
final medium = state.mediumMap[previewUrl];
if (medium == null) {
return const SizedBox();
}
switch (medium) {
case RenderingType.image:
return InteractiveViewer(
minScale: 1,
maxScale: 4,
child: Center(
child: ImageNFTRenderingWidget(
previewURL: previewUrl,
),
),
);
case RenderingType.video:
return InteractiveViewer(
minScale: 1,
maxScale: 4,
child: Center(
child: VideoNFTRenderingWidget(
key: Key('video_nft_rendering_widget_$previewUrl'),
previewURL: previewUrl,
thumbnailURL: thumbnailUrl,
),
),
);
case RenderingType.gif:
return InteractiveViewer(
minScale: 1,
maxScale: 4,
child: Center(
child: GifNFTRenderingWidget(
previewURL: previewUrl,
),
builder: (context, attempt) =>
BlocBuilder<FFArtworkPreviewBloc, FFArtworkPreviewState>(
bloc: context.read<FFArtworkPreviewBloc>(),
builder: (context, state) {
final medium = state.mediumMap[previewUrl];
if (medium == null) {
return const SizedBox();
}
switch (medium) {
case RenderingType.image:
return InteractiveViewer(
minScale: 1,
maxScale: 4,
child: Center(
child: ImageNFTRenderingWidget(
previewURL: previewUrl,
),
);
case RenderingType.svg:
return InteractiveViewer(
minScale: 1,
maxScale: 4,
child: Center(
child: SVGNFTRenderingWidget(previewURL: previewUrl)),
);
case RenderingType.pdf:
return Center(
child: PDFNFTRenderingWidget(
),
);
case RenderingType.video:
return InteractiveViewer(
minScale: 1,
maxScale: 4,
child: Center(
child: VideoNFTRenderingWidget(
key: Key('video_nft_rendering_widget_$previewUrl'),
previewURL: previewUrl,
thumbnailURL: thumbnailUrl,
isMute: widget.payload.isMute,
),
);
default:
return Center(
child: WebviewNFTRenderingWidget(
),
);
case RenderingType.gif:
return InteractiveViewer(
minScale: 1,
maxScale: 4,
child: Center(
child: GifNFTRenderingWidget(
previewURL: previewUrl,
),
);
}
},
);
},
),
);
case RenderingType.svg:
return InteractiveViewer(
minScale: 1,
maxScale: 4,
child: Center(
child: SVGNFTRenderingWidget(previewURL: previewUrl)),
);
case RenderingType.pdf:
return Center(
child: PDFNFTRenderingWidget(
previewURL: previewUrl,
),
);
default:
return Center(
child: WebviewNFTRenderingWidget(
previewURL: previewUrl,
isMute: widget.payload.isMute,
),
);
}
},
),
),
);
}
Expand Down

0 comments on commit 5a025d4

Please sign in to comment.