import { _decorator, Component, Node, find, VideoPlayer } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('NewComponent')
export class NewComponent extends Component {
    start() {
        let video = find('Canvas/VideoPlayer').getComponent(VideoPlayer);
        video.node.on(VideoPlayer.EventType.READY_TO_PLAY, this.ready, this);
        video.node.on(VideoPlayer.EventType.META_LOADED, this.meta, this);
        video.node.on(VideoPlayer.EventType.ERROR, this.verror, this);
        video.node.on(VideoPlayer.EventType.PLAYING, this.playing, this);
        video.node.on(VideoPlayer.EventType.COMPLETED, this.complete, this);
        video.node.on(VideoPlayer.EventType.PAUSED, this.pause, this);
        video.node.on(VideoPlayer.EventType.STOPPED, this.stop, this);
        video.node.on(VideoPlayer.EventType.CLICKED, this.click, this);
        video.node.on(VideoPlayer.EventType.NONE, this.vnone, this);


    }
    ready (){
        find('Canvas/VideoPlayer').getComponent(VideoPlayer).play();
    }

    meta(){
        console.log('meta');
        this.schedule(()=>{
            find('Canvas/VideoPlayer').getComponent(VideoPlayer).play();

        },3)
    }

    verror(){
        console.log('verror');
    }

    playing(){
        console.log('playing');
    }

    complete(){
        console.log('complete');
    }

    pause(){
        console.log('pause');
    }

    stop(){
        console.log('stop');
    }

    click(){
        console.log('click');
    }

    vnone(){
        console.log('vnone');
    }
    update(deltaTime: number) {
        
    }
}

