android加载flash动画效果,使用 SVGAPlayer 在 Android、iOS、Web中播放 After Effects / Animate CC (Flash) 动画...

SVGAPlayer

68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f53564741506c617965722d416e64726f69642f6261636b6572732f62616467652e73766768747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f53564741506c617965722d416e64726f69642f73706f6e736f72732f62616467652e737667

Introduce

SVGAPlayer is a light-weight animation renderer. You use tools to export svga file from Adobe Animate CC or Adobe After Effects, and then use SVGAPlayer to render animation on mobile application.

SVGAPlayer-Android render animation natively via Android Canvas Library, brings you a high-performance, low-cost animation experience.

If wonder more information, go to this website.

Usage

Here introduce SVGAPlayer-Android usage. Wonder exporting usage? Click here.

Install Via Gradle

We host aar file on JitPack, your need to add JitPack.io repo build.gradle

allprojects {

repositories {

...

maven { url 'https://jitpack.io' }

}

}

Then, add dependency to app build.gradle.

compile 'com.github.yyued:SVGAPlayer-Android:latest'

68747470733a2f2f6a69747061636b2e696f2f762f79797565642f53564741506c617965722d416e64726f69642e737667

Static Parser Support

Perser#shareParser should be init(context) in Application or other Activity. Otherwise it will report an error: Log.e("SVGAParser", "在配置 SVGAParser context 前, 无法解析 SVGA 文件。")

Matte Support

Proguard-rules

-keep class com.squareup.wire.** { *; }

-keep class com.opensource.svgaplayer.proto.** { *; }

Locate files

SVGAPlayer could load svga file from Android assets directory or remote server.

Using XML

You may use layout.xml to add a SVGAImageView.

xmlns:app="http://schemas.android.com/apk/res-auto"

android:orientation="vertical"

android:layout_width="match_parent"

android:layout_height="match_parent">

android:layout_height="match_parent"

android:layout_width="match_parent"

app:source="posche.svga"

app:autoPlay="true"

android:background="#000" />

The following attributes is allowable:

source: String

The svga file path, provide a path relative to Android assets directory, or provide a http url.

autoPlay: Boolean

Defaults to true.

After animation parsed, plays animation automatically.

loopCount: Int

Defaults to 0.

How many times should animation loops. 0 means Infinity Loop.

clearsAfterStop: Boolean

Defaults to true.

Clears canvas after animation stop.

fillMode: String

Defaults to Forward. Could be Forward, Backward.

Forward means animation will pause on last frame after finished.

Backward means animation will pause on first frame after finished.

Using code

You may use code to add SVGAImageView either.

Create a SVGAImageView instance.

SVGAImageView imageView = new SVGAImageView(this);

Declare a static Parser instance.

parser = SVGAParser.shareParser()

Init parser instance

You should initialize the parser instance with context before usage.

SVGAParser.shareParser().init(this);

Otherwise it will report an error: Log.e("SVGAParser", "在配置 SVGAParser context 前, 无法解析 SVGA 文件。")

You can also create SVGAParser instance by yourself.

Create a SVGAParser instance, parse from assets like this.

parser = new SVGAParser(this);

parser.decodeFromAssets("posche.svga", new SVGAParser.ParseCompletion() {

// ...

});

Create a SVGAParser instance, parse from remote server like this.

parser = new SVGAParser(this);

parser.decodeFromURL(new URL("https://github.com/yyued/SVGA-Samples/blob/master/posche.svga?raw=true"), new SVGAParser.ParseCompletion() {

});

Create a SVGADrawable instance then set to SVGAImageView, play it as you want.

parser = new SVGAParser(this);

parser.decodeFromURL(..., new SVGAParser.ParseCompletion() {

@Override

public void onComplete(@NotNull SVGAVideoEntity videoItem) {

SVGADrawable drawable = new SVGADrawable(videoItem);

imageView.setImageDrawable(drawable);

imageView.startAnimation();

}

@Override

public void onError() {

}

});

Cache

SVGAParser will not manage any cache, you need to setup cacher by yourself.

Setup HttpResponseCache

SVGAParser depends on URLConnection, URLConnection uses HttpResponseCache to cache things.

Add codes to Application.java:onCreate to setup cacher.

val cacheDir = File(context.applicationContext.cacheDir, "http")

HttpResponseCache.install(cacheDir, 1024 * 1024 * 128)

Features

Here are many feature samples.

APIs

CHANGELOG

Head on over to CHANGELOG

Credits

Contributors

This project exists thanks to all the people who contribute. [Contribute].

68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f53564741506c617965722d416e64726f69642f636f6e7472696275746f72732e7376673f77696474683d38393026627574746f6e3d66616c7365

Backers

Thank you to all our backers!

🙏 [Become a backer]

68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f53564741506c617965722d416e64726f69642f6261636b6572732e7376673f77696474683d383930

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f53564741506c617965722d416e64726f69642f73706f6e736f722f302f6176617461722e737667

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值