I quite often get the following expcetion when opening videos:
โโโโโโโโ Exception caught by image resource service โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
The following NetworkImageLoadException was thrown resolving an image codec:
HTTP request failed, statusCode: 404, https://i3.ytimg.com/vi_webp/BP979AMuuP8/sddefault.webp
When the exception was thrown, this was the stack
#0 NetworkImage._loadAsync
package:flutter/โฆ/painting/_network_image_io.dart:90
<asynchronous suspension>
#1 NetworkImage.load
package:flutter/โฆ/painting/_network_image_io.dart:47
#2 ImageProvider.resolveStreamForKey.<anonymous closure>
package:flutter/โฆ/painting/image_provider.dart:491
#3 ImageCache.putIfAbsent
package:flutter/โฆ/painting/image_cache.dart:344
...
Image provider: NetworkImage("https://i3.ytimg.com/vi_webp/BP979AMuuP8/sddefault.webp", scale: 1.0)
Image key: NetworkImage("https://i3.ytimg.com/vi_webp/BP979AMuuP8/sddefault.webp", scale: 1.0)
I think the thumbnail image needs to be loaded in a way to handle 404 errors.
Having the same issue... there must be a way to add Alternative thumbnail image if the youtube video doesn't have one.
@jwhijazi you can specify a thumbnail for the video, although if you do it will not attempt to fetch the youtube one.
The behavior you have described is possible but it would require the YT thumbnail to be loaded in a different way to catch the 404 and then use the fallback image. I'm a bit too busy at the moment otherwise I would implement this.
@jimmyff
No problem... Once you have time it will be a good fix.
Thanks,
Same, anyone have a solution?
this is how i solved the problem. The problem is that if you hit the above URL few times, then it blocks the client, hence the error.
However, Youtube provide's thumbnail images for all its videos. Just insert the videoID in the provided URL.
YoutubePlayer(
controller: _controller,
thumbnailUrl: "https://img.youtube.com/vi/${videoID}/hqdefault.jpg",
)
@dheerajsarwaiya there is no param for thumbnailUrl in the plugin, can you please describe the same, I'm getting the same exception again and again.
After 7.0.0+2 he removed the thumbnailUrl. Now you can use any widget in thumbnail parameter.
Added thumbnail parameter to YoutubePlayer, removed thumbnailUrl. Now any widget can be used as thumbnail.
@dheerajsarwaiya If I'm getting it correct, the thumbnail param only shows the respective widget till the youtube player loads the correct thumbnail. Correct me if I'm wrong.
no .. it shows whatever you set in thumbnail. If you dont set it, then it will show whatever it get from the video.. I do this
thumbnailUrl: "https://img.youtube.com/vi/${widget.videoID}/hqdefault.jpg",
Most helpful comment
no .. it shows whatever you set in thumbnail. If you dont set it, then it will show whatever it get from the video.. I do this
thumbnailUrl: "https://img.youtube.com/vi/${widget.videoID}/hqdefault.jpg",