fix video loading and error

This commit is contained in:
Salvatore Giordano
2020-04-10 17:13:28 +02:00
parent 793ae5f93a
commit e58f2a1f35
+10 -1
View File
@@ -1038,8 +1038,12 @@ class _MessageWidgetState extends State<MessageWidget>
future: videoController.initialize(), future: videoController.initialize(),
builder: (_, snapshot) { builder: (_, snapshot) {
if (snapshot.connectionState != ConnectionState.done) { if (snapshot.connectionState != ConnectionState.done) {
return Center( return Container(
height: 100,
width: 100,
child: Center(
child: CircularProgressIndicator(), child: CircularProgressIndicator(),
),
); );
} }
ChewieController chewieController; ChewieController chewieController;
@@ -1052,6 +1056,7 @@ class _MessageWidgetState extends State<MessageWidget>
autoInitialize: false, autoInitialize: false,
aspectRatio: videoController.value.aspectRatio, aspectRatio: videoController.value.aspectRatio,
errorBuilder: (_, e) { errorBuilder: (_, e) {
if (attachment.thumbUrl != null) {
return Stack( return Stack(
children: <Widget>[ children: <Widget>[
Container( Container(
@@ -1064,6 +1069,7 @@ class _MessageWidgetState extends State<MessageWidget>
), ),
), ),
), ),
if (attachment.titleLink != null)
Material( Material(
color: Colors.transparent, color: Colors.transparent,
child: InkWell( child: InkWell(
@@ -1072,6 +1078,9 @@ class _MessageWidgetState extends State<MessageWidget>
), ),
], ],
); );
}
return _buildErrorImage(attachment);
}); });
_chuwieControllers[attachment.assetUrl] = chewieController; _chuwieControllers[attachment.assetUrl] = chewieController;
} }