import { Laya } from "Laya" ; import { Sprite } from "laya/display/Sprite" ; import { Stage } from "laya/display/Stage" ; import { Event } from "laya/events/Event" ; import { Render } from "laya/renders/Render" ; import { Browser } from "laya/utils/Browser" ; import { Utils } from "laya/utils/Utils" ; import { Main } from "./../Main" ; author export class DOM_Video { Main : typeof Main = null ; constructor ( maincls ) { this . Main = maincls ; Laya . init ( 800 , 600 ) ; Laya . stage . bgColor = "#FFFFFF" ; Laya . stage . alignH = Stage . ALIGN_CENTER ; Laya . stage . alignV = Stage . ALIGN_MIDDLE ; var videoElement = Browser . createElement ( "video" ) ; Browser . document . body . appendChild ( videoElement ) ; videoElement . style . zInddex = Render . canvas . style . zIndex + 1 ; videoElement . src = "res/av/mov_bbb.mp4" ; videoElement . controls = true ; videoElement . setAttribute ( "webkit-playsinline" , true ) ; videoElement . setAttribute ( "playsinline" , true ) ; var reference = new Sprite ( ) ; this . Main . box2D . addChild ( reference ) ; reference . pos ( 100 , 100 ) ; reference . size ( 600 , 400 ) ; reference . graphics . drawRect ( 0 , 0 , reference . width , reference . height , "#CCCCCC" ) ; Laya . stage . on ( Event . RESIZE , this , Utils . fitDOMElementInArea , [ videoElement , reference , 0 , 0 , reference . width , reference . height ] ) ; } }