Fresco Android GIF / WEBP动画无法播放

时间:2016-08-11 09:45:30

标签: android fresco

我决定使用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,我还需要做其他步骤吗?或者我误解了文档使用动画'?

编辑:

附加信息,在使用ControllerListener时,我发现onFinalImageSet()中的Animatable返回值为null。我不确定为什么。

我也试过运行这个示例项目,但.gif也没有动画:https://github.com/kaedea/fresco-sample-usage

我使用Nexus 5X测试btw(版本6.0.1)

1 个答案:

答案 0 :(得分:6)

确保添加Gradle dependencies for animations

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'
}