protected void Page_Load(object sender, EventArgs e) { VideoRepository videoRepository = new VideoRepository(); LiveBroadcastRepository liveBroadcastRepository = new LiveBroadcastRepository(); // Determine if the user can access private videos bool includePrivateContent = false; List <Video> NewestVideos = videoRepository.GetNewest(includePrivateContent, 60); List <Video> FeaturedVideos = videoRepository.GetFeatured(includePrivateContent); List <LiveBroadcast> UpcomingStreams = liveBroadcastRepository.GetUpcoming(); List <LiveBroadcast> CurrentlyLiveStreams = liveBroadcastRepository.GetLive(); // Display live streams currently broadcasting if (CurrentlyLiveStreams.Count > 0) { if (CurrentlyLiveStreams.Count == 1) { if (CurrentlyLiveStreams.First().EmbedInsteadOfLink) { litPlayer.Visible = true; litStreamInfo.Visible = true; litPlayer.Text = YoutubeLiveBroadcastPlayer.GetHTML(CurrentlyLiveStreams.First()); litStreamInfo.Text = buildLiveStreamInfoHTML(CurrentlyLiveStreams.First()); } else { litLiveStreams.Visible = true; litLiveStreams.Text = showMultipleLiveStreams(CurrentlyLiveStreams); } } else { litLiveStreams.Visible = true; litLiveStreams.Text = showMultipleLiveStreams(CurrentlyLiveStreams); } } else { litPlayer.Visible = false; litStreamInfo.Visible = false; litLiveStreams.Visible = false; } // Display upcoming streams if (UpcomingStreams.Count > 0) { title_upcoming.Visible = true; litUpcomingStreams.Visible = true; litUpcomingStreams.Text = upcomingStreamsSection(UpcomingStreams); } else { title_upcoming.Visible = false; litUpcomingStreams.Visible = false; } // Display newest videos (if any exist) if (NewestVideos.Count > 0) { litNewestVideos.Visible = true; litNewestVideos.Text = newestVideosSection(NewestVideos); } else { litNewestVideos.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Request.QueryString["i"])) { // Sanitize the video ID string requestedID = Sanitizers.SanitizeQueryStringID(Request.QueryString["i"]); // See if this video exists LiveBroadcastRepository liveBroadcastRepository = new LiveBroadcastRepository(); LiveBroadcast liveStream = liveBroadcastRepository.Get(requestedID); if (liveStream != null) { // Determine if the viewer is viewing from inside the network string clientIP = Request.ServerVariables["REMOTE_ADDR"]; bool canUserAccessPrivateContent = Config.CanAccessPrivate(clientIP); // Set the page title string originalTitle = Page.Header.Title; Page.Header.Title = liveStream.Name + " - " + originalTitle; if (liveStream.IsEnded && !liveStream.ForcedLive) { displayError("This live stream has ended."); } else { if ( ((liveStream.IsPrivate) && (canUserAccessPrivateContent)) || (!liveStream.IsPrivate)) { tblContainer.Visible = true; if (liveStream.EmbedInsteadOfLink) { litPlayer.Text = YoutubeLiveBroadcastPlayer.GetHTML(liveStream); } else { if (!string.IsNullOrEmpty(liveStream.YouTubeID)) { Response.Redirect(@"https://www.youtube.com/watch?v=" + liveStream.YouTubeID); } else { displayError("Live stream has no Youtube ID set"); } } litStreamInfo.Text = streamInfoBox(liveStream); } else { displayError("This live stream is marked as private. You can only watch from within the LSKYSD network."); } } } else { displayError("A live stream with that ID does not exist."); } } else { displayError("Stream ID not specified."); } }