Commit 4f61b4c1 authored by wjf's avatar wjf

l

parent cd2ef6e7
......@@ -17,7 +17,7 @@ export class Parser {
load(url: string, success: (videoItem: VideoEntity) => void, failure?: (err: Error) => void): void
}
export class EgretMovieClip {
export class EgretMovieClip extends egret.DisplayObjectContainer {
lockStep: boolean;
readonly currentFrame: number;
readonly isPlaying: boolean;
......@@ -49,8 +49,8 @@ export class EgretMovieClip {
* 帧数范围播放
* @param beginFrame 默认第一帧
* @param endFrame 默认最后一帧
* @param loops 默认0,表示无限循环
* @param callback 所有播放完的回调
* @param loops 默认0,表示无限循环,无限循环callback无效,因为永远不会完成,用正常的complete监听最后一帧或第一帧
* @param callback 所有播放完的回调
*/
startAniRange(beginFrame: number, endFrame: number, loops: number, callback?: Function): void
constructor(mv: VideoEntity)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -141,53 +141,19 @@ export class MovieClip extends egret.DisplayObjectContainer {
this.frameCount = this.deltaFrame;
this._curFrame = 1;
//缓存所有图片
var self = this;
const images = mv.images;
let countAll = Object.getOwnPropertyNames(images).length;
let count = 0;
for (let key in images) {
var bitmap = images[key];
// let imgTag = document.createElement('img');
let imgTag = new Image();
let backCanvas;
if (bitmap.indexOf("iVBO") === 0 || bitmap.indexOf("/9j/2w") === 0) {
imgTag.src = 'data:image/png;base64,' + bitmap;
}
else {
// imgTag.src = bitmap;
// if (frames[0] && frames[0].layout) {
// backCanvas = document.createElement('canvas');
// backCanvas.width = frames[0].layout.width
// backCanvas.height = frames[0].layout.height
// imgTag.onload = function () {
// backCanvas.getContext('2d').drawImage(imgTag, 0, 0, frames[0].layout.width, frames[0].layout.height)
// }
// }
}
//必须加载完成才行
imgTag.onload = function () {
count++;
var bitmapData = new egret.BitmapData(backCanvas || imgTag);
var texture = new egret.Texture();
texture.bitmapData = bitmapData;
self.textures[key] = texture;
if (count == countAll) {
self.initChildren(mv.sprites);
//到时找替代的方法,用这个去循环好像,移除了还在执行
self.addEventListener(egret.Event.ENTER_FRAME, function () {
self.updateFrame()
}, self)
}
}
// Texture.addToCache(this.textures[key], key)
let imgTag = images[key];
var bitmapData = new egret.BitmapData(imgTag);
var texture = new egret.Texture();
texture.bitmapData = bitmapData;
this.textures[key] = texture;
}
this.initChildren(mv.sprites);
//到时找替代的方法,用这个去循环好像,移除了还在执行
this.addEventListener(egret.Event.ENTER_FRAME, function () {
this.updateFrame()
}, this)
}
initChildren(sprites) {
......
......@@ -16,8 +16,38 @@ export class Parser {
let movie = data.movie;
movie["version"] = data.ver;
let images = data.images;
let videoItem = new VideoEntity(movie, images);
success(videoItem);
let countAll = Object.getOwnPropertyNames(images).length;
let count = 0;
let htmlImages = {};
for (let key in images) {
var bitmap = images[key];
let imgTag = new Image();
let backCanvas;
if (bitmap.indexOf("iVBO") === 0 || bitmap.indexOf("/9j/2w") === 0) {
imgTag.src = 'data:image/png;base64,' + bitmap;
}
else {
// imgTag.src = bitmap;
// if (frames[0] && frames[0].layout) {
// backCanvas = document.createElement('canvas');
// backCanvas.width = frames[0].layout.width
// backCanvas.height = frames[0].layout.height
// imgTag.onload = function () {
// backCanvas.getContext('2d').drawImage(imgTag, 0, 0, frames[0].layout.width, frames[0].layout.height)
// }
// }
}
//必须加载完成才行
imgTag.onload = function () {
count++;
htmlImages[key] = backCanvas || imgTag;
if (count == countAll) {
let videoItem = new VideoEntity(movie, htmlImages);
success(videoItem);
}
}
}
}, failure)
}
......
......@@ -28,6 +28,7 @@ export class VideoEntity {
/**
* Bitmaps
* 白鹭版本,这个直接是html Image标签
*/
images = {};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment