Load PAG File
Network Loading
The PAG SDK focuses on animation rendering and does not have a built-in network module, so please use the network module to load animation files yourself.
Taking the browser API fetch
as an example, the codes to load the animation file are as follows:
fetch("https://pag.qq.com/file/like.pag").then(response => {
return response.arrayBuffer(); // [<font color=blue> PAG filt </font>](/docs/en/terms.html#pag-file)
})
PAG File Decoding
Use PAGFile.load()
to decode a PAG file into a PAGFile
object:
const { PAGFile } = PAG; // PAG object instantiated from PAGInit
PAGFile.load(arrayBuffer).then(pagFile => {
// Get the PAGFile object
})
Get File Information
Get the size of the PAG file:
const width = pagFile.width();
const height = pagFile.height();
Get the duration of the PAG file:
const duration = pagFile.duration();
Get frame rate of the PAG file:
const frameRate = pagFile.frameRate();