public void LoadSongsFromDB() { playlist = DatabaseManager.SelectAllSongsFromNowPlaying(); currentIndex = ApplicationSettingsHelper.ReadSongIndex(); if (currentIndex >= playlist.Count) { currentIndex = playlist.Count - 1; } //if (currentIndex < 0) //{ // currentIndex = 0; //} lastPlayed.Clear(); if (playlist.Count < 20) { maxQueueSize = playlist.Count; } else if (playlist.Count > 60) { maxQueueSize = 15; } else { maxQueueSize = 10 + (playlist.Count / 4); } }
public void Activate(object parameter, Dictionary <string, object> state) { ascending = true; Playlist.Clear(); genre = null; directory = null; folderName = null; isSmart = false; IsNowPlaying = true; IsDeletable = true; id = 0; name = ""; index = 0; if (parameter != null) { if (parameter.GetType() == typeof(string)) { String[] s = ParamConvert.ToStringArray(parameter as string); if (s.Length >= 2 && s[0].Equals("genre")) { genre = s[1]; IsDeletable = false; } else if (s.Length >= 3 && s[0].Equals("folder")) { folderName = s[1]; directory = s[2]; IsDeletable = false; } else { if (s.Length >= 2 && s[0].Equals("smart")) { isSmart = true; IsDeletable = false; } if (s.Length >= 3 && (s[0].Equals("smart") || s[0].Equals("plain"))) { id = Int32.Parse(s[1]); name = s[2]; } } IsNowPlaying = false; } } if (isNowPlaying) { index = ApplicationSettingsHelper.ReadSongIndex(); } if (state != null) { if (state.ContainsKey("index")) { index = (int)state["index"]; } } }
public SongItem GetCurrentPlayingSong() { try { return(NowPlayingList[ApplicationSettingsHelper.ReadSongIndex()]); } catch (Exception ex) { Diagnostics.Logger.Save("GetCurrentPlayingSong" + Environment.NewLine + ex.Message); Diagnostics.Logger.SaveToFile(); } return(null); }
public void CheckNPAfterUpdate(IEnumerable <int> toAvailable) { List <SongItem> list = new List <SongItem>(); foreach (var song in nowPlayingList) { if (toAvailable.Contains(song.SongId)) { list.Add(song); } } if (list.Count <= ApplicationSettingsHelper.ReadSongIndex()) { ApplicationSettingsHelper.SaveSongIndex(list.Count - 1); } SetNowPlayingList(list); }
void App_UnhandledException(object sender, UnhandledExceptionEventArgs e) { Logger.SaveInSettings(e.Exception.ToString() + "\nMessage:\n" + e.Message); if (e != null) { Exception exception = e.Exception; if (exception is NullReferenceException && exception.ToString().ToUpper().Contains("SOMA")) { Debug.WriteLine("Handled Smaato null reference exception {0}", exception); e.Handled = true; return; } else if (exception.ToString().Contains("AdDuplex")) { e.Handled = true; return; } } ApplicationSettingsHelper.ReadResetSettingsValue(AppConstants.MediaScan); int i = ApplicationSettingsHelper.ReadSongIndex(); int npc = Library.Current.NowPlayingList.Count; if (i >= 0 && npc > 0 && npc > i) { ApplicationSettingsHelper.SaveSongIndex(i); } else { ApplicationSettingsHelper.SaveSongIndex(-1); if (npc >= 0) { ApplicationSettingsHelper.SaveSongIndex(0); } } DiagnosticHelper.TrackTrace("Unhandled Exception " + e.Exception.ToString() + "\n" + e.Message, Microsoft.HockeyApp.SeverityLevel.Error); }