uniapp原生插件之安卓SVGA动画原生插件

插件介绍

安卓SVGA插件是原生组件式插件,支持SVGA动画文件格式播放,支持网络地址播放

插件地址

安卓SVGA动画原生插件 - DCloud 插件市场

详细使用文档

uniapp 安卓SVGA动画原生插件

超级福利

uniapp 插件购买超级福利

用法

插件权限

  • android.permission.INTERNET
  • android.permission.WRITE_EXTERNAL_STORAGE
  • android.permission.READ_EXTERNAL_STORAGE

插件引入

在需要使用插件的页面加载以下代码

javascript 复制代码
<leven-svga ref="refLevenSvga" style="height: 500rpx; width: 750rpx;" @onComplete="onComplete" @onError="onError" @onPlay="onPlay"
@onPause="onPause" @onFinished="onFinished" @onRepeat="onRepeat" @onStep="onStep" @onLoadingStart="onLoadingStart" @onLoading="onLoading"
@onLoadingSuccess="onLoadingSuccess"></leven-svga>

完整页面内容

html 复制代码
<template>
  <view>
    <view>
      <uni-card title="uniappSVGA原生插件">
        <leven-svga ref="refLevenSvga" style="height: 500rpx; width: 750rpx;" @onComplete="onComplete" @onError="onError" @onPlay="onPlay"
          @onPause="onPause" @onFinished="onFinished" @onRepeat="onRepeat" @onStep="onStep" @onLoadingStart="onLoadingStart" @onLoading="onLoading"
          @onLoadingSuccess="onLoadingSuccess"></leven-svga>
        <button type="primary" @click="logStr = ''">清空日志</button>
        <button type="primary" @click="play">开始播放</button>
        <button type="primary" @click="pause">暂停播放</button>
        <button type="primary" @click="resumePlay">继续播放</button>
        <button type="primary" @click="stop">结束播放</button>
      </uni-card>
    </view>
    <view>
      <uni-card class="uni-card-box" title="日志">
        <view><text style="font-size: 14px; flex-wrap: wrap;">{{logStr}}</text></view>
      </uni-card>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        logStr: ""
      }
    },
    methods: {
      // 开始播放
      play() {
        if (this.$refs.refLevenSvga) {
          this.$refs.refLevenSvga.play({
            path: "/static/1.svga",
            loop: 1, //循环播放次数,0.无限循环,1.循环一次
          }, res => {
            this.writeLog(JSON.stringify(res));
          });
        }
      },
      // 暂停播放
      pause() {
        if (this.$refs.refLevenSvga) {
          this.$refs.refLevenSvga.pause();
        }
      },
      // 继续播放
      resumePlay() {
        if (this.$refs.refLevenSvga) {
          this.$refs.refLevenSvga.resumePlay();
        }
      },
      // 暂停播放
      stop() {
        if (this.$refs.refLevenSvga) {
          this.$refs.refLevenSvga.stop({
            clear: false
          }, res => {
            this.writeLog(JSON.stringify(res));
          });
        }
      },
      // 加载完成
      onComplete(e) {
        this.writeLog(JSON.stringify(e));
      },
      // 加载错误
      onError(e) {
        this.writeLog(JSON.stringify(e));
      },
      // 开始播放
      onPlay(e) {
        this.writeLog(JSON.stringify(e));
      },
      // 暂停播放
      onPause(e) {
        this.writeLog(JSON.stringify(e));
      },
      // 播放完成
      onFinished(e) {
        this.writeLog(JSON.stringify(e));
      },
      // 重复播放
      onRepeat(e) {
        this.writeLog(JSON.stringify(e));
      },
      // 停止播放
      onStep(e) {
        this.writeLog(JSON.stringify(e));
      },
      // 开始加载(网络地址有效)
      onLoadingStart(e) {
        this.writeLog(JSON.stringify(e));
      },
      // 加载中(网络地址有效)
      onLoading(e) {
        // this.writeLog(JSON.stringify(e));
      },
      // 加载完成(网络地址有效)
      onLoadingSuccess(e) {
        this.writeLog(JSON.stringify(e));
      },
      // 写日志
      writeLog(str) {
        // let logStr = uni.$lv.date.format(null, "yyyy-mm-dd hh:MM:ss") + " " + str + "\n";
        // this.logStr = logStr + this.logStr;
        console.log(str)
      }
    }
  }
</script>

<style>

</style>

插件方法

  • 开始播放 play
  • 暂停播放 pause
  • 继续播放 resumePlay
  • 停止播放 stop

插件事件

  • 加载完成 onComplete
  • 加载错误 onError
  • 开始播放 onPlay
  • 暂停播放 onPause
  • 重复播放 onRepeat
  • 播放进度 onStep
  • 播放结束 onFinished
  • 网络地址开始加载 onLoadingStart
  • 网络地址加载中 onLoading
  • 网络地址加载完成 onLoadingSuccess

具体方法和事件的使用请参考详细使用文档

联系作者

购买插件前请先试用,试用通过再购买。在试用中如果遇到任何问题,可与作者联系,QQ:334106817,将全力协助你使用本插件

预览图片

相关推荐
飞天狗1115 分钟前
零基础JavaWeb入门——第4课:表单处理 —— 浏览器怎么把数据发给服务器
java·开发语言·前端·后端·servlet
多彩电脑11 分钟前
向AIDE(安卓设备上的Android Studio)导入aar库
android·java·开发语言·androidx
Hooray23 分钟前
前端暗黑模式的适配艺术
前端·vue.js·视觉设计
恋猫de小郭24 分钟前
解析华为 DevEco Code 和小米 MiMo Code,都基于 OpenCode ,有什么区别?
android·前端·ios
IT_陈寒26 分钟前
Vue的响应式让我原地裂开,你们也有这情况吗
前端·人工智能·后端
2501_9327502636 分钟前
Android 控件与布局全面解析
android
想吃火锅100541 分钟前
【leetcode】20.有效的括号js
linux·javascript·leetcode
问心无愧051343 分钟前
ctfshow web入门114
android·前端·笔记
aaaa9547266543 分钟前
终端与IDE形态Vibe Coding实测:主流AI编程工具迁移与迭代对比
javascript·react.js·ecmascript
黄林晴1 小时前
离谱!Android 17藏神仙功能,手机录屏叠加真人出镜
android