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); } }
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(); }