Fresco Android无法播放GIF/WEBP动画。

4
我决定使用 Fresco ,因为它提供了解决我的问题: GIFWEBP 播放的方案。
根据文档:http://frescolib.org/docs/animations.html 我可以使用以下代码来自动播放动画:
   Uri uri;
   DraweeController controller = Fresco.newDraweeControllerBuilder()
       .setUri(uri)
       .setAutoPlayAnimations(true)
       . // other setters
       .build();
   mSimpleDraweeView.setController(controller);

然而,当我使用这段代码时,它只显示静态图片。我需要采取其他步骤才能播放GIF/WEBP吗?或者是我误解了文档中“animation”的用法?
编辑:使用ControllerListener后,我发现onFinalImageSet()返回的Animatable对象为空。我不确定原因。
我还尝试运行了此示例项目,但.gif文件也没有动画效果:https://github.com/kaedea/fresco-sample-usage 顺便说一下,我的测试设备是Nexus 5X(版本6.0.1)。

好的,问题在于我没有添加支持GIF和WebP格式的模块。 - kishidp
1个回答

7

请确保您添加了与动画相关的Gradle依赖项

dependencies {
  // If your app supports Android versions before Ice Cream Sandwich (API level 14)
  compile 'com.facebook.fresco:animated-base-support:1.2.0'

  // For animated GIF support
  compile 'com.facebook.fresco:animated-gif:1.2.0'

  // For WebP support, including animated WebP
  compile 'com.facebook.fresco:animated-webp:1.2.0'
  compile 'com.facebook.fresco:webpsupport:1.2.0'

  // For WebP support, without animations
  compile 'com.facebook.fresco:webpsupport:1.2.0'
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接