private static List <Asset> FilterEntries(IdAsset[] urls) { if (urls == null) { return(new List <Asset>()); } ; //if no URLS, return an empty list var time = (DateTime.Now.Hour < 6 || DateTime.Now.Hour > 19) ? "night" : "day"; var ran = new Random(); var settings = new RegSettings(); List <Asset> links = urls.SelectMany(s => s.assets) .Where(t => AssetSelected(t)) //only return videos that have been selected to be played .OrderBy(t => ran.Next()) // randomize .OrderByDescending(t => settings.UseTimeOfDay && t.timeOfDay == time) .ToList(); //If the links list is empty or null for some reason, just populate with all movies if (links == null || links.Count == 0) { links = urls.SelectMany(s => s.assets).ToList(); } if (settings.DifferentMoviesOnDual) { return(links); } if (cachedPlaylist == null) { cachedPlaylist = links; } return(cachedPlaylist); }
public List <Asset> GetMovies() { var entries = GetEntries(); var urls = new JavaScriptSerializer().Deserialize <IdAsset[]>(entries); var time = (DateTime.Now.Hour < 6 || DateTime.Now.Hour > 19) ? "night" : "day"; var ran = new Random(); var settings = new RegSettings(); var links = urls.SelectMany(s => s.assets) .OrderBy(t => ran.Next()) .OrderByDescending(t => settings.UseTimeOfDay && t.timeOfDay == time) .ToList(); if (settings.DifferentMoviesOnDual) { return(links); } if (cachedPlaylist == null) { cachedPlaylist = links; } return(cachedPlaylist); }
public static IdAsset[] GetAllEntries() { if (cachedEntities != null) { return(cachedEntities); } var settings = new RegSettings(); var aerialUrl = settings.JsonURL; #if OFFLINE aerialUrl = "http://BOGUS/entries.json"; #endif // update anyway Caching.StartDelayedCache(aerialUrl); string entries = ""; if (Caching.IsHit(aerialUrl)) { entries = File.ReadAllText(Caching.Get(aerialUrl)); } else { WebClient webClient = new WebClient(); entries = webClient.DownloadString(aerialUrl); } cachedEntities = new JavaScriptSerializer().Deserialize <IdAsset[]>(entries); return(cachedEntities); }
/// <summary> /// Display the form on each of the computer's monitors. /// </summary> static void ShowScreenSaver() { var multiMonitorMode = new RegSettings().MultiMonitorMode; switch (multiMonitorMode) { case RegSettings.MultiMonitorModeEnum.SameOnEach: case RegSettings.MultiMonitorModeEnum.DifferentVideos: { foreach (var screen in Screen.AllScreens) { new ScreenSaverForm(screen.Bounds, shouldCache: screen.Primary, showVideo: true).Show(); } break; } case RegSettings.MultiMonitorModeEnum.SpanAll: { new ScreenSaverForm(Screen.AllScreens.GetBounds(), shouldCache: true, showVideo: true).Show(); break; } case RegSettings.MultiMonitorModeEnum.MainOnly: default: { foreach (var screen in Screen.AllScreens) { new ScreenSaverForm(screen.Bounds, shouldCache: screen.Primary, showVideo: screen.Primary).Show(); } break; } } }
/** * Returns true if the asset (movie) is in the chosen movies in the registry key, false if it isn't */ private static bool AssetSelected(Asset a) { var settings = new RegSettings(); //if no movies are selected to be played, just allow all if (String.IsNullOrEmpty(settings.ChosenMovies)) { return(true); } var selected = new RegSettings().ChosenMovies.Split(';').ToList(); List <string> selectedIds = selected.Select(s => GetIdFromTimeAndIdNumbered(s)).ToList();; return(selectedIds.Contains(a.id)); }
public static IdAsset[] GetAllEntries() { if (cachedEntities != null) { return(cachedEntities); } var settings = new RegSettings(); var aerialUrl = settings.JsonURL; #if OFFLINE aerialUrl = "http://BOGUS/entries.json"; #endif //aerialUrl = "https://smukfestmedia.blob.core.windows.net/video/custom-entries.json"; aerialUrl = "C:\\Users\\ros\\Source\\Repos\\Aerial\\ScreenSaver\\custom-entries.json"; // update anyway Caching.StartDelayedCache(aerialUrl); string entries = ""; if (Caching.IsHit(aerialUrl)) { entries = File.ReadAllText(Caching.Get(aerialUrl)); } else { WebClient webClient = new WebClient(); entries = webClient.DownloadString(aerialUrl); } try { cachedEntities = new JavaScriptSerializer().Deserialize <IdAsset[]>(entries); } catch (ArgumentException e) { //the passed in entities document is invalid. return(null); } return(cachedEntities); }
/// <summary> /// Display the form on each of the computer's monitors. /// </summary> static void ShowScreenSaver() { int i = 0; var multiscreenDisabled = new RegSettings().MultiscreenDisabled; foreach (Screen screen in Screen.AllScreens) { bool showVideo = true; // disable video on multi-displays (3+) except the first if (Screen.AllScreens.Length > 2 && screen != Screen.PrimaryScreen && multiscreenDisabled) { showVideo = false; } ScreenSaverForm screensaver = new ScreenSaverForm(screen.Bounds, i == 0, showVideo); screensaver.Show(); i++; } }
private static List <Asset> FilterEntries(IdAsset[] urls) { var time = (DateTime.Now.Hour < 6 || DateTime.Now.Hour > 19) ? "night" : "day"; var ran = new Random(); var settings = new RegSettings(); List <Asset> links = urls.SelectMany(s => s.assets) .OrderBy(t => ran.Next()) // randomize .OrderByDescending(t => settings.UseTimeOfDay && t.timeOfDay == time) .ToList(); if (settings.DifferentMoviesOnDual) { return(links); } if (cachedPlaylist == null) { cachedPlaylist = links; } return(cachedPlaylist); }
public static IdAsset[] GetAllEntries() { if (cachedEntities != null) { return(cachedEntities); } var settings = new RegSettings(); var aerialUrl = settings.JsonURL; #if OFFLINE aerialUrl = "http://BOGUS/entries.json"; #endif // update anyway Caching.StartDelayedCache(aerialUrl); string entries = ""; if (Caching.IsHit(aerialUrl)) { entries = File.ReadAllText(Caching.Get(aerialUrl)); } else { WebClient webClient = new WebClient(); try { entries = webClient.DownloadString(aerialUrl); } catch (Exception ex) { ex.ToString(); //return null; } } try { cachedEntities = new JavaScriptSerializer().Deserialize <IdAsset[]>(entries); } catch (ArgumentException e) { return(null); } catch { //the passed in entities document is invalid. try { dynamic cached = ConvertToDynamicObject(entries); var cachedTempEntities = new List <IdAsset>(); var datas = cached.data; foreach (var data in datas) { var idAsset = new IdAsset(); idAsset.id = Guid.NewGuid().ToString(); //idAsset.assets = new Asset[data.screensavers.Count]; var assets = new List <Asset>(); foreach (var screensaver in data.screensavers) { var asset = new Asset(); asset.accessibilityLabel = data.name; asset.id = screensaver.identifier; asset.name = screensaver.identifier; asset.url = screensaver.videoURL;//screensaver.urls.h264; asset.timeOfDay = "year"; asset.type = "video"; assets.Add(asset); } idAsset.assets = assets.ToArray(); cachedTempEntities.Add(idAsset); } cachedEntities = cachedTempEntities.ToArray(); } catch (Exception ex) { return(null); } } return(cachedEntities); }