展示(使用Egret Inspector调试查看)

问题
完整代码
class VideoTest extends egret.DisplayObjectContainer {
    private video: egret.Video;
    public constructor() {
        super();
        this.addEventListener(egret.Event.ADDED_TO_STAGE, this.createVideo, this);
    }
    private createVideo(event: egret.Event) {
        this.video = new egret.Video();
        this.video.width = 640; //设置视频宽
        this.video.height = 320; //设置视频高
        this.video.fullscreen = false; //设置是否全屏(暂不支持移动设备)
        this.video.poster = "resource/assets/loading.png"; //设置loding图
        this.video.load("http://media.w3.org/2010/05/sintel/trailer.mp4");
        this.addChild(this.video); //将视频添加到舞台
        //监听视频加载完成
        this.video.once(egret.Event.COMPLETE, this.onLoad, this);
        //监听视频加载失败
        this.video.once(egret.IOErrorEvent.IO_ERROR, this.onLoadErr, this);
    }
    private onLoad(e: egret.Event) {
        /**
         * 播放
         */
        const btnPlay: eui.Button = new eui.Button(); //新建播放按钮
        btnPlay.label = "播放";
        btnPlay.x = this.video.x + 20;
        btnPlay.y = this.video.y + this.video.height + 20;
        this.addChild(btnPlay);
        //监听按钮行为,当按下时调用播放函数。
        btnPlay.addEventListener(egret.TouchEvent.TOUCH_TAP, function (e: egret.TouchEvent) {
            this.video.play();
        }, this);
        /**
         * 暂停
         */
        const btnPause: eui.Button = new eui.Button(); //新建播放按钮
        btnPause.label = "暂停";
        btnPause.x = btnPlay.x + 100;
        btnPause.y = this.video.y + this.video.height + 20;
        this.addChild(btnPause);
        //监听按钮行为,当按下时调用播放函数。
        btnPause.addEventListener(egret.TouchEvent.TOUCH_TAP, function (e: egret.TouchEvent) {
            this.video.pause();
        }, this);
        /**
         * 截图
         */
        const btnPrintScreen: eui.Button = new eui.Button();
        btnPrintScreen.label = "截图";
        btnPrintScreen.x = btnPause.x + 100;
        btnPrintScreen.y = this.video.y + this.video.height + 20;
        this.addChild(btnPrintScreen);
        btnPrintScreen.addEventListener(egret.TouchEvent.TOUCH_TAP, function (e: egret.TouchEvent) {
            const bitmap: egret.Bitmap = new egret.Bitmap();
            // 截取容器1图片到容器2中进行展示
            const renderTexture: egret.RenderTexture = new egret.RenderTexture();
            renderTexture.drawToTexture(this.video, new egret.Rectangle(this.video.x, this.video.y, this.video.width, this.video.height)); // x y width height
            bitmap.texture = renderTexture;
            bitmap.x = this.video.x;
            bitmap.y = this.video.y + this.video.height + 150;
            this.addChild(bitmap);
        }, this);
        /**
         * 音量
         */
        const volume: eui.HSlider = new eui.HSlider();
        volume.x = btnPrintScreen.x + 120;
        volume.y = this.video.y + this.video.height + 30;
        this.addChild(volume);
        volume.value = 100;
        volume.maximum = 100;
        volume.minimum = 0;
        volume.width = 200;
        volume.addEventListener(egret.Event.CHANGE, function (e: egret.TouchEvent) {
            this.video.volume = e.target.value / 100;
        }, this);
        /**
         * 设置全屏播放开关按钮
         */
        const screenSwitcher: eui.ToggleSwitch = new eui.ToggleSwitch();
        screenSwitcher.label = "全屏";
        screenSwitcher.x = volume.x + 220;
        screenSwitcher.y = this.video.y + this.video.height + 630;
        screenSwitcher.addEventListener(egret.Event.CHANGE, function (e: egret.TouchEvent) {
            //当开关被选择后。该开关的selected属性将变为true,反之则为false
            this.video.fullscreen = e.target.selected;
            console.log(e.target.selected);
        }, this);
        this.addChild(screenSwitcher);
        /**
         * 使用label标签来显示文字,并监听`ENTER_FRAME`事件来更新显示。
         */
        const position: eui.Label = new eui.Label();
        position.x = btnPlay.x;
        position.y = this.video.y + this.video.height + 100;
        this.addChild(position);
        position.addEventListener(egret.Event.ENTER_FRAME, function (e: egret.TouchEvent) {
            //当开关被选择后。该开关的selected属性将变为true,反之则为false
            e.target.text = "播放时间: " + this.video.position;
        }, this);
        //获取视频长度
        console.log(this.video.length);
        
    }
    private onLoadErr(e: egret.Event) {
        console.log("video load error happened");
    }
}                









