var bricks = window.bricks || {}; /* we use videojs for video play https://videojs.com event: play_end video play finished play_failed video play failed play_ok video start to play */ bricks.VideoBody = class extends bricks.Layout { constructor(opts){ super(opts||{}); this.set_css('video-js'); this.set_css('vjs-big-play-centered'); this.set_css('vjs-fluid'); this.cur_url = opts.url; this.cur_vtype = opts.type; } create(){ var e; e = document.createElement('video'); this.dom_element = e; e.controls = true; } } bricks.Video = class extends bricks.Layout { /* { vtype: url: autoplay: } */ constructor(options){ super(options); this.video_body = new bricks.VideoBody(options); this.add_widget(this.video_body); schedule_once(this.create_player.bind(this), 0.1); this.hidedbtn = new bricks.Button({text:'click me'}); this.hidedbtn.hide(); this.add_widget(this.hidedbtn); } destroy_resource(params, event){ var w = event.target.bricks_widget; if (! w.parent){ bricks.debug('destroy resource .......'); this.player.pause(); this.player.dispose(); this.player = null; } } disable_captions(){ this.player.nativeTextTracks = false; var tt = this.player.textTracks() bricks.debug('textTracks=', tt); if (tt){ for(var i=0;i