Commit 4f61b4c1 authored by wjf's avatar wjf

l

parent cd2ef6e7
...@@ -17,7 +17,7 @@ export class Parser { ...@@ -17,7 +17,7 @@ export class Parser {
load(url: string, success: (videoItem: VideoEntity) => void, failure?: (err: Error) => void): void load(url: string, success: (videoItem: VideoEntity) => void, failure?: (err: Error) => void): void
} }
export class EgretMovieClip { export class EgretMovieClip extends egret.DisplayObjectContainer {
lockStep: boolean; lockStep: boolean;
readonly currentFrame: number; readonly currentFrame: number;
readonly isPlaying: boolean; readonly isPlaying: boolean;
...@@ -49,8 +49,8 @@ export class EgretMovieClip { ...@@ -49,8 +49,8 @@ export class EgretMovieClip {
* 帧数范围播放 * 帧数范围播放
* @param beginFrame 默认第一帧 * @param beginFrame 默认第一帧
* @param endFrame 默认最后一帧 * @param endFrame 默认最后一帧
* @param loops 默认0,表示无限循环 * @param loops 默认0,表示无限循环,无限循环callback无效,因为永远不会完成,用正常的complete监听最后一帧或第一帧
* @param callback 所有播放完的回调 * @param callback 所有播放完的回调
*/ */
startAniRange(beginFrame: number, endFrame: number, loops: number, callback?: Function): void startAniRange(beginFrame: number, endFrame: number, loops: number, callback?: Function): void
constructor(mv: VideoEntity) 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 { ...@@ -141,53 +141,19 @@ export class MovieClip extends egret.DisplayObjectContainer {
this.frameCount = this.deltaFrame; this.frameCount = this.deltaFrame;
this._curFrame = 1; this._curFrame = 1;
//缓存所有图片
var self = this;
const images = mv.images; const images = mv.images;
let countAll = Object.getOwnPropertyNames(images).length;
let count = 0;
for (let key in images) { for (let key in images) {
var bitmap = images[key]; let imgTag = images[key];
// let imgTag = document.createElement('img'); var bitmapData = new egret.BitmapData(imgTag);
let imgTag = new Image(); var texture = new egret.Texture();
let backCanvas; texture.bitmapData = bitmapData;
if (bitmap.indexOf("iVBO") === 0 || bitmap.indexOf("/9j/2w") === 0) { this.textures[key] = texture;
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)
} }
this.initChildren(mv.sprites);
//到时找替代的方法,用这个去循环好像,移除了还在执行
this.addEventListener(egret.Event.ENTER_FRAME, function () {
this.updateFrame()
}, this)
} }
initChildren(sprites) { initChildren(sprites) {
......
...@@ -16,8 +16,38 @@ export class Parser { ...@@ -16,8 +16,38 @@ export class Parser {
let movie = data.movie; let movie = data.movie;
movie["version"] = data.ver; movie["version"] = data.ver;
let images = data.images; 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) }, failure)
} }
......
...@@ -28,6 +28,7 @@ export class VideoEntity { ...@@ -28,6 +28,7 @@ export class VideoEntity {
/** /**
* Bitmaps * Bitmaps
* 白鹭版本,这个直接是html Image标签
*/ */
images = {}; 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