--[[ 该界面放到了SpecialView下面 在线上看到了一些报错,android.media.MediaPlayer.reset()' on a null object reference 怀疑是关闭该界面很短时间内再打开导致后台创建的线程没有销毁,导致线程资源被清理导致 ]] local UILoginVideo = UIViewClass() local PATH = "Movie/%s" function UILoginVideo:OnCreated() self.controller_Movie:SetAndroidOESEnabled(true) end function UILoginVideo:OnOpened(context) self:RegistSystemEvent(EventID.UI_Login_SwitchPicAndVideo, self.SwitchPicAndVideo) self.loginShowType = context.loginShowType self.loginShowPath = context.loginShowPath self:RefreshUI() end function UILoginVideo:SwitchPicAndVideo(context) if context.loginShowType ~= self.loginShowType then self.loginShowType = context.loginShowType self.loginShowPath = context.loginShowPath self:RefreshUI() end end function UILoginVideo:RefreshUI() if self.loginShowType == MDL.Login.LoginBGTypeEnum.Texture then self.tex = TK2API.GetTextureAsset(self.loginShowPath) self.TextureBG.texture = self.tex --暂时先延迟处理,因为初始化UI的Canvas在协程里执行,这个时候还无法拿到canvas的大小 self:StartRepeatFunc(self.DelayShowTexture, 0.5, 1) else UIUtils.SetActive(self.Video, true) UIUtils.SetActive(self.Texture, false) self.controller_Movie:PlayMovie(string.format(PATH, self.loginShowPath)) end end function UILoginVideo:DelayShowTexture() UIUtils.SetActive(self.Video, false) UIUtils.SetActive(self.Texture, true) end function UILoginVideo:OnClosed() if self.loginShowType == MDL.Login.LoginBGTypeEnum.Texture then TK2API.ReturnAsset(self.loginShowPath, self.tex) self.tex = nil end end return UILoginVideo