private void EditServiceShow(int id)
        {
            StreamingLiveLib.Service service = (id == 0) ? new StreamingLiveLib.Service()
            {
                SiteId = AppUser.Current.Site.Id
            } : StreamingLiveLib.Service.Load(id, AppUser.Current.Site.Id);
            ServiceEditHolder.Visible   = true;
            ServiceListHolder.Visible   = false;
            DeleteServiceHolder.Visible = id != 0;

            ServiceIdHid.Value = id.ToString();

            ProviderList.SelectedValue = "custom_watchparty";
            if (id > 0)
            {
                VideoUrlText.Text = service.VideoUrl;

                EarlyStartMinText.Text = StreamingLiveLib.Utils.GetMinutes(service.EarlyStart).ToString();
                EarlyStartSecText.Text = StreamingLiveLib.Utils.GetSeconds(service.EarlyStart).ToString();

                DurationMinText.Text = StreamingLiveLib.Utils.GetMinutes(service.Duration).ToString();
                DurationSecText.Text = StreamingLiveLib.Utils.GetSeconds(service.Duration).ToString();

                ChatBeforeText.Text = StreamingLiveLib.Utils.GetMinutes(service.ChatBefore).ToString();
                ChatAfterText.Text  = StreamingLiveLib.Utils.GetMinutes(service.ChatAfter).ToString();

                DateTime localServiceTime = service.ServiceTime;
                localServiceTime       = localServiceTime.AddMinutes(-Convert.ToInt32(TZOffsetHid.Value));
                CountdownTimeText.Text = localServiceTime.ToString("yyyy-MM-dd") + "T" + localServiceTime.ToString("HH:mm");
                VimeoKeyText.Text      = service.ProviderKey;
                YouTubeKeyText.Text    = service.ProviderKey;
                FacebookKeyText.Text   = service.ProviderKey;
                try
                {
                    ProviderList.SelectedValue = service.Provider;
                }
                catch { }

                RecurringList.SelectedValue = service.Recurring.ToString();
            }
            else
            {
                DateTime serviceTime = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 9, 0, 0);
                while (serviceTime.DayOfWeek != DayOfWeek.Sunday)
                {
                    serviceTime = serviceTime.AddDays(1);
                }
                CountdownTimeText.Text = serviceTime.ToString("yyyy-MM-dd") + "T" + serviceTime.ToString("HH:mm");
                EarlyStartMinText.Text = "15";
                EarlyStartSecText.Text = "0";
                DurationMinText.Text   = "60";
                DurationSecText.Text   = "0";
                ChatBeforeText.Text    = "15";
                ChatAfterText.Text     = "15";
            }

            ShowProviderDetails();
            DeleteServiceButton.Visible = id > 0;
        }
        protected void SaveServiceButton_Click(object sender, EventArgs e)
        {
            int earlyStart = 0;
            int duration   = 0;
            int chatBefore = 0;
            int chatAfter  = 0;

            earlyStart = StreamingLiveLib.Utils.GetTotalSeconds(EarlyStartMinText.Text, EarlyStartSecText.Text);
            duration   = StreamingLiveLib.Utils.GetTotalSeconds(DurationMinText.Text, DurationSecText.Text);
            chatBefore = StreamingLiveLib.Utils.GetTotalSeconds(ChatBeforeText.Text, "0");
            chatAfter  = StreamingLiveLib.Utils.GetTotalSeconds(ChatAfterText.Text, "0");

            string[] errors = ValidateService();
            if (errors.Length == 0)
            {
                int id = Convert.ToInt32(ServiceIdHid.Value);
                StreamingLiveLib.Service service = (id == 0) ? new StreamingLiveLib.Service()
                {
                    SiteId = AppUser.Current.Site.Id
                } : StreamingLiveLib.Service.Load(id, AppUser.Current.Site.Id);
                service.VideoUrl       = VideoUrlText.Text;
                service.EarlyStart     = earlyStart;
                service.Duration       = duration;
                service.TimezoneOffset = Convert.ToInt32(TZOffsetHid.Value);
                service.ServiceTime    = Convert.ToDateTime(CountdownTimeText.Text).AddMinutes(service.TimezoneOffset);
                service.Provider       = ProviderList.SelectedValue;
                service.ProviderKey    = "";
                service.ChatBefore     = chatBefore;
                service.ChatAfter      = chatAfter;
                service.Recurring      = Convert.ToBoolean(RecurringList.SelectedValue);

                switch (ProviderList.SelectedValue)
                {
                case "youtube_live":
                case "youtube_watchparty":
                    service.ProviderKey = YouTubeKeyText.Text;
                    service.VideoUrl    = $"https://www.youtube.com/embed/{YouTubeKeyText.Text}?autoplay=1&controls=0&showinfo=0&rel=0&modestbranding=1&disablekb=1";
                    break;

                case "vimeo_live":
                case "vimeo_watchparty":
                    service.ProviderKey = VimeoKeyText.Text;
                    service.VideoUrl    = $"https://player.vimeo.com/video/{VimeoKeyText.Text}?autoplay=1";
                    break;

                case "facebook_live":
                    service.ProviderKey = FacebookKeyText.Text;
                    service.VideoUrl    = $"https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2Fvideo.php%3Fv%3D{FacebookKeyText.Text}&show_text=0&autoplay=1&allowFullScreen=1";
                    break;
                }
                service.Save();
                UpdateData();
            }
            else
            {
                OutputMessage("<b>Error:</b><ul><li>" + String.Join("</li><li>", errors) + "</li></ul>", true, ServiceOutputLit);
            }
        }
示例#3
0
        public void OnPostSave()
        {
            int earlyStart = 0;
            int duration   = 0;
            int chatBefore = 0;
            int chatAfter  = 0;

            earlyStart = StreamingLiveLib.Utils.GetTotalSeconds(EarlyStartMin, EarlyStartSec);
            duration   = StreamingLiveLib.Utils.GetTotalSeconds(DurationMin, DurationSec);
            chatBefore = StreamingLiveLib.Utils.GetTotalSeconds(ChatBefore, 0);
            chatAfter  = StreamingLiveLib.Utils.GetTotalSeconds(ChatAfter, 0);

            string[] errors = ValidateService();
            if (errors.Length == 0)
            {
                StreamingLiveLib.Service service = (ServiceId == 0) ? new StreamingLiveLib.Service()
                {
                    SiteId = AppUser.Current.Site.Id
                } : StreamingLiveLib.Service.Load(ServiceId, AppUser.Current.Site.Id);
                service.VideoUrl       = VideoKey;
                service.EarlyStart     = earlyStart;
                service.Duration       = duration;
                service.TimezoneOffset = TimezoneOffset;
                service.ServiceTime    = Convert.ToDateTime(CountdownTime).AddMinutes(service.TimezoneOffset);
                service.Provider       = Provider;
                service.ProviderKey    = VideoKey;
                service.ChatBefore     = chatBefore;
                service.ChatAfter      = chatAfter;
                service.Recurring      = RecursWeekly;

                switch (Provider)
                {
                case "youtube_live":
                case "youtube_watchparty":
                    service.VideoUrl = $"https://www.youtube.com/embed/{VideoKey}?autoplay=1&controls=0&showinfo=0&rel=0&modestbranding=1&disablekb=1";
                    break;

                case "vimeo_live":
                case "vimeo_watchparty":
                    service.VideoUrl = $"https://player.vimeo.com/video/{VideoKey}?autoplay=1";
                    break;

                case "facebook_live":
                    service.VideoUrl = $"https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2Fvideo.php%3Fv%3D{VideoKey}&show_text=0&autoplay=1&allowFullScreen=1";
                    break;
                }
                service.Save();
            }
            OutputMessage = Utils.FormatMessage("<b>Error:</b><ul><li>" + String.Join("</li><li>", errors) + "</li></ul>", true);
            UpdateData();
        }
        protected void ServiceRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            LinkButton EditButton     = (LinkButton)e.Item.FindControl("EditButton");
            Literal    ServiceTimeLit = (Literal)e.Item.FindControl("ServiceTimeLit");

            StreamingLiveLib.Service service = (StreamingLiveLib.Service)e.Item.DataItem;

            DateTime localServiceTime = service.ServiceTime.AddMinutes(-service.TimezoneOffset);

            ServiceTimeLit.Text = localServiceTime.ToString();


            EditButton.CommandArgument = service.Id.ToString();
        }
示例#5
0
        private void EditServiceShow()
        {
            SelectedService = (ServiceId == 0) ? new StreamingLiveLib.Service()
            {
                SiteId = AppUser.Current.Site.Id
            } : StreamingLiveLib.Service.Load(ServiceId, AppUser.Current.Site.Id);
            Provider = "custom_watchparty";
            if (ServiceId > 0)
            {
                VideoKey      = SelectedService.VideoUrl;
                EarlyStartMin = StreamingLiveLib.Utils.GetMinutes(SelectedService.EarlyStart);
                EarlyStartSec = StreamingLiveLib.Utils.GetSeconds(SelectedService.EarlyStart);

                DurationMin = StreamingLiveLib.Utils.GetMinutes(SelectedService.Duration);
                DurationSec = StreamingLiveLib.Utils.GetSeconds(SelectedService.Duration);

                ChatBefore = StreamingLiveLib.Utils.GetMinutes(SelectedService.ChatBefore);
                ChatAfter  = StreamingLiveLib.Utils.GetMinutes(SelectedService.ChatAfter);

                DateTime localServiceTime = SelectedService.ServiceTime;
                localServiceTime = localServiceTime.AddMinutes(-SelectedService.TimezoneOffset);
                CountdownTime    = localServiceTime.ToString("yyyy-MM-dd") + "T" + localServiceTime.ToString("HH:mm");
                VideoKey         = SelectedService.ProviderKey;
                Provider         = SelectedService.Provider;
                RecursWeekly     = SelectedService.Recurring;
                ServiceId        = SelectedService.Id;
            }
            else
            {
                DateTime serviceTime = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 9, 0, 0);
                while (serviceTime.DayOfWeek != DayOfWeek.Sunday)
                {
                    serviceTime = serviceTime.AddDays(1);
                }
                CountdownTime = serviceTime.ToString("yyyy-MM-dd") + "T" + serviceTime.ToString("HH:mm");
                EarlyStartMin = 15;
                EarlyStartSec = 0;
                DurationMin   = 60;
                DurationSec   = 0;
                ChatBefore    = 15;
                ChatAfter     = 15;
            }
            Populate();
        }