Example #1
0
        void SetSize(VideoPopUpDataModel videoPopUpDataModel)
        {
            //Set size
            var size = videoPopUpDataModel.popUpSetting.size;

            switch (videoPopUpDataModel.popUpSetting.sizeOption)
            {
            case SizeOption.FixedContentSize:
                size = new Vector2((int)video.width, (int)video.height);
                break;

            case SizeOption.FixedPercentage:
                var rect = transform.GetComponentInParent <Canvas>().GetComponent <RectTransform>().sizeDelta;

                float height = rect.y * ((float)videoPopUpDataModel.popUpSetting.percentage / 100.0f);
                float width  = (rect.x / rect.y) * height - 100;   //100 referes control panel width

                size = new Vector2(width, height);

                break;
            }

            //video.GetComponent<RawImage>().color = Color.black;
            SetContentSize(size);
            PlacePopUp(rectTransform);
        }
Example #2
0
        public void Init(VideoPopUpDataModel popupDataModel)
        {
            this.videoPopUpDataModel = popupDataModel;

            video.source = popupDataModel.popUpSetting.video.videoSource;

            if (video.source == VideoSource.VideoClip)
            {
                video.clip = popupDataModel.popUpSetting.video.videoClip;
            }
            else
            {
                video.url = popupDataModel.popUpSetting.video.videoURL;
            }

            SetCloseButtonImage(imageCloseButton, popupDataModel.popUpSetting); //Set Close Button

            pauseButton.SetActive(popupDataModel.popUpSetting.controlPanelStyle != ControlPanelStyle.RestartAndClose && popupDataModel.popUpSetting.controlPanelStyle != ControlPanelStyle.OnlyClose);
            restartButton.SetActive(popupDataModel.popUpSetting.controlPanelStyle != ControlPanelStyle.PlayPauseAndClose && popupDataModel.popUpSetting.controlPanelStyle != ControlPanelStyle.OnlyClose);

            if (popupDataModel.popUpSetting.closeAfterPlay)
            {
                video.loopPointReached += VideoComplete;
            }

            if (!popupDataModel.popUpSetting.closeAfterPlay && popupDataModel.popUpSetting.loop)
            {
                video.isLooping = true;
            }

            //Once video has loaded it will resize the player correctly
            video.prepareCompleted += ResizeVideoPlayer;
        }