Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

frame-player

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

frame-player

Frame Player

  • 1.1.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

frame-player

License MIT NPM Version

图片序列帧播放器,代替 gif、video 播放

Install

  • 本地
npm i -S frame-player
import FramePlayer from 'frame-player'

const framePlayer = new FramePlayer(options)
  • CDN
<script src="//unpkg.com/frame-player"></script>

API

class: FramePlayer(options)

  • options <Object>
    • canvas <string|HTMLCanvasElement> 画布选择器 | 画布对象。默认 "canvas"
    • width <number> 绘制宽度(当设置了 css width 时,作为绘制比例)
    • height <number> 绘制高度(当设置了 css height 时,作为绘制比例)
    • images <Array<string>> 图片路径数组
    • fps <number> 帧率。默认 24
    • loop <number> 循环播放次数。-1 为无限循环,默认 0 不循环
    • alternate <boolean> 是否轮流反向播放,配合 loop 使用才有效果。默认 false
    • transparent <boolean> 图片是否透明,true 每次绘制前清空画布。默认 false
    • autoPlay <boolean> 是否自动播放,true 会在图片 ready 后立即播放。默认 false
FramePlayer.version
  • returns: <number> 获取当前版本号
event: 'loading'

正在加载图片的事件,可用于画面上显示加载进度

event: 'ready'

所有图片加载完成的事件

event: 'play'

开始播放的事件

event: 'update'

播放每一帧的事件

event: 'stop'

停止播放的事件

framePlayer.on(event, fn)

事件监听

framePlayer.play([desc])
  • desc <boolean> 是否反向播放。默认 false

播放动画,将从之前 stop() 的位置继续播放,默认从 0 开始

framePlayer.stop([frame])
  • frame <number> 停止的帧索引。默认 当前播放索引

停止播放,也可以传入 frame 跳帧到指定位置

framePlayer.frame
  • returns: <number> 获取当前播放帧索引

FAQs

Package last updated on 31 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc