From: <sa...@us...> - 2010-03-01 19:15:27
|
Revision: 3474 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=3474&view=rev Author: saamand Date: 2010-03-01 16:20:24 +0000 (Mon, 01 Mar 2010) Log Message: ----------- Version 1.4.2.3 (beta) Modified Paths: -------------- trunk/plugins/MyLyrics/LyricsEngine/LyricUtil.cs trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs trunk/plugins/MyLyrics/My Lyrics/change log.txt trunk/plugins/MyLyrics/TranslateProvider/bin/Debug/TranslateProvider.dll trunk/plugins/MyLyrics/TranslateProvider/bin/Debug/TranslateProvider.pdb trunk/plugins/MyLyrics/TranslateProvider/obj/Debug/TranslateProvider.dll trunk/plugins/MyLyrics/TranslateProvider/obj/Debug/TranslateProvider.pdb Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricUtil.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricUtil.cs 2010-02-25 16:13:33 UTC (rev 3473) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricUtil.cs 2010-03-01 16:20:24 UTC (rev 3474) @@ -12,15 +12,14 @@ /*, "ä", "ö", "ü", "Ä", "Ö", "Ü", "ß" */ }; - private static readonly string[] parenthesesAndAlike = new string[6] - {"(album", "(acoustic", "(live", "(radio", "[", "{"}; + private static readonly string[] parenthesesAndAlike = new string[3] { "(", "[", "{" }; // capatalize string and make ready for XML public static string CapatalizeString(string s) { s = s.Replace("\"", ""); - char[] space = new char[1] {' '}; + char[] space = new char[1] { ' ' }; string[] words = s.Split(space, StringSplitOptions.RemoveEmptyEntries); StringBuilder result = new StringBuilder(); Modified: trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs =================================================================== --- trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs 2010-02-25 16:13:33 UTC (rev 3473) +++ trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs 2010-03-01 16:20:24 UTC (rev 3474) @@ -18,7 +18,7 @@ using MediaPortal.Playlists; using MediaPortal.Profile; using MediaPortal.TagReader; -using Timer=System.Timers.Timer; +using Timer = System.Timers.Timer; namespace MyLyrics { @@ -102,14 +102,16 @@ private bool _useLyricWiki; private bool _ValidLrcLyric; - // A valid LRC-lyric always overwrites a normal lyric in both Lyrics db and music tag (if allowed) + // A valid LRC-lyric always overwrites a normal lyric in both Lyrics db and music tag (if allowed) private Timer _WriteTagTimer; #endregion - [SkinControl((int) GUI_LRC_Controls.CONTROL_ART_ALBUMART)] protected GUIImage GUIelement_ImgCoverArt; - [SkinControl((int) GUI_LRC_Controls.CONTROL_ART_PROGRESS)] protected GUIProgressControl GUIelement_ProgTrack; + [SkinControl((int)GUI_LRC_Controls.CONTROL_ART_ALBUMART)] + protected GUIImage GUIelement_ImgCoverArt; + [SkinControl((int)GUI_LRC_Controls.CONTROL_ART_PROGRESS)] + protected GUIProgressControl GUIelement_ProgTrack; private int _SearchType; @@ -131,7 +133,7 @@ #region Fields releated to the editor mode internal const int _TAG_IN_ROUND = 13; - internal int _currentLRCLineIndex; + internal int nextLRCLineIndex; private string[] _lines; internal int _LRCLinesTotal; internal int _min; @@ -154,7 +156,7 @@ public override bool Init() { - _selectedScreen = (int) MyLyricsSettings.Screen.LYRICS; + _selectedScreen = (int)MyLyricsSettings.Screen.LYRICS; _startingScrollSpeedVertical = GUIGraphicsContext.ScrollSpeedVertical; GUIGraphicsContext.ScrollSpeedVertical = 0; @@ -165,7 +167,7 @@ public override void Process() { - if ((_newTrack || _SearchingState != (int) SEARCH_STATE.NOT_SEARCHING) + if ((_newTrack || _SearchingState != (int)SEARCH_STATE.NOT_SEARCHING) && (!g_Player.IsRadio || !string.IsNullOrEmpty(_artist))) { if (_newTrack) @@ -180,7 +182,7 @@ MusicDatabase mDB = MusicDatabase.Instance; - GUIControl.SetControlLabel(GetID, (int) GUI_LRC_Controls.CONTROL_LRCPICK_STATUS, ""); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_LRCPICK_STATUS, ""); if (g_Player.IsRadio == false) { @@ -196,6 +198,7 @@ _title = _CurrentTrackTag.Title.Trim(); _title = _title.Replace("''", "'"); _title = LyricUtil.CapatalizeString(_title); + _title = LyricUtil.TrimForParenthesis(_title); GetAlbumArt(); GetAlbumArt(_artist); @@ -203,7 +206,9 @@ else { _StatusText = "No music file is playing"; - GUIControl.SetControlLabel(GetID, (int) GUI_General_Controls.CONTROL_LBStatus, _StatusText); + resetLrcFields(); + resetGUI(_selectedScreen); + GUIControl.SetControlLabel(GetID, (int)GUI_General_Controls.CONTROL_LBStatus, _StatusText); } } else @@ -223,26 +228,26 @@ _CurrentTrackTag.Lyrics = LyricUtil.FixLyrics(_CurrentTrackTag.Lyrics); } - if (_selectedScreen == (int) MyLyricsSettings.Screen.LYRICS - || _selectedScreen == (int) MyLyricsSettings.Screen.LRC - || _selectedScreen == (int) MyLyricsSettings.Screen.LRC_PICK) + if (_selectedScreen == (int)MyLyricsSettings.Screen.LYRICS + || _selectedScreen == (int)MyLyricsSettings.Screen.LRC + || _selectedScreen == (int)MyLyricsSettings.Screen.LRC_PICK) { // Get lyric if (_artist.Length != 0) { - if (_SearchingState == (int) SEARCH_STATE.NOT_SEARCHING) + if (_SearchingState == (int)SEARCH_STATE.NOT_SEARCHING) { - if (_SearchType == (int) SEARCH_TYPES.BOTH_LRCS_AND_LYRICS - || _SearchType == (int) SEARCH_TYPES.ONLY_LRCS) + if (_SearchType == (int)SEARCH_TYPES.BOTH_LRCS_AND_LYRICS + || _SearchType == (int)SEARCH_TYPES.ONLY_LRCS) { bool lrcFoundInTagOrLyricDb = FindLrc(); if (lrcFoundInTagOrLyricDb) { - _SearchingState = (int) SEARCH_STATE.NOT_SEARCHING; + _SearchingState = (int)SEARCH_STATE.NOT_SEARCHING; } else { - _SearchingState = (int) SEARCH_STATE.SEARCHING_FOR_LRC; + _SearchingState = (int)SEARCH_STATE.SEARCHING_FOR_LRC; } } else @@ -250,32 +255,32 @@ bool lyricFoundInTagOrLyricDb = FindLyric(); if (lyricFoundInTagOrLyricDb) { - _SearchingState = (int) SEARCH_STATE.NOT_SEARCHING; + _SearchingState = (int)SEARCH_STATE.NOT_SEARCHING; } else { - _SearchingState = (int) SEARCH_STATE.SEARCHING_FOR_LYRIC; + _SearchingState = (int)SEARCH_STATE.SEARCHING_FOR_LYRIC; } } } - else if (_SearchingState == (int) SEARCH_STATE.SEARCHING_FOR_LRC && + else if (_SearchingState == (int)SEARCH_STATE.SEARCHING_FOR_LRC && !_LyriccontrollerIsWorking) { - if (_SearchType == (int) SEARCH_TYPES.BOTH_LRCS_AND_LYRICS - || _SearchType == (int) SEARCH_TYPES.ONLY_LYRICS) + if (_SearchType == (int)SEARCH_TYPES.BOTH_LRCS_AND_LYRICS + || _SearchType == (int)SEARCH_TYPES.ONLY_LYRICS) { FindLyric(); - _SearchingState = (int) SEARCH_STATE.SEARCHING_FOR_LYRIC; + _SearchingState = (int)SEARCH_STATE.SEARCHING_FOR_LYRIC; } else { - _SearchingState = (int) SEARCH_STATE.NOT_SEARCHING; + _SearchingState = (int)SEARCH_STATE.NOT_SEARCHING; } } - else if (_SearchingState == (int) SEARCH_STATE.SEARCHING_FOR_LYRIC && + else if (_SearchingState == (int)SEARCH_STATE.SEARCHING_FOR_LYRIC && !_LyriccontrollerIsWorking) { - _SearchingState = (int) SEARCH_STATE.NOT_SEARCHING; + _SearchingState = (int)SEARCH_STATE.NOT_SEARCHING; } } else @@ -286,14 +291,16 @@ _LyricText = ""; _StatusText = "No music file playing"; + resetLrcFields(); + resetGUI(_selectedScreen); - GUIControl.SetControlLabel(GetID, (int) GUI_General_Controls.CONTROL_LBStatus, _StatusText); + GUIControl.SetControlLabel(GetID, (int)GUI_General_Controls.CONTROL_LBStatus, _StatusText); } } - else if (_selectedScreen == (int) MyLyricsSettings.Screen.LRC_EDITOR) + else if (_selectedScreen == (int)MyLyricsSettings.Screen.LRC_EDITOR) { _newTrack = false; - _currentLRCLineIndex = 0; + nextLRCLineIndex = 0; _LRCLinesTotal = 0; _tagRoundFinished = 0; @@ -332,7 +339,7 @@ _LyricText = ""; _StatusText = "No music file playing"; - GUIControl.SetControlLabel(GetID, (int) GUI_General_Controls.CONTROL_LBStatus, + GUIControl.SetControlLabel(GetID, (int)GUI_General_Controls.CONTROL_LBStatus, _StatusText); } } @@ -342,8 +349,8 @@ if (_lyricsFound) { - if (_selectedScreen == (int) MyLyricsSettings.Screen.LRC - || _selectedScreen == (int) MyLyricsSettings.Screen.LRC_PICK) + if (_selectedScreen == (int)MyLyricsSettings.Screen.LRC + || _selectedScreen == (int)MyLyricsSettings.Screen.LRC_PICK) { CalculateNextInterval(); } @@ -366,28 +373,28 @@ if (lrc.IsValid) { _alreadyValidLRC = true; - _lines = new string[1] {"This song already has a valid LRC lyric."}; + _lines = new string[1] { "This song already has a valid LRC lyric." }; - GUIControl.SetControlLabel(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_LINE + 0, _lines[0]); - GUIControl.SetControlLabel(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_LINE_DONE + 0, _lines[0]); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE + 0, _lines[0]); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE_DONE + 0, _lines[0]); } else { - _lines = _LyricText.Split(new string[2] {"\r\n", "\n"}, StringSplitOptions.None); + _lines = _LyricText.Split(new string[2] { "\r\n", "\n" }, StringSplitOptions.None); try { - for (int i = _tagRoundFinished*_TAG_IN_ROUND; - i < (_tagRoundFinished + 1)*_TAG_IN_ROUND; + for (int i = _tagRoundFinished * _TAG_IN_ROUND; + i < (_tagRoundFinished + 1) * _TAG_IN_ROUND; i++) { - GUIControl.ShowControl(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_LINE + i); - GUIControl.ShowControl(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_LINE_DONE + i); - GUIControl.ShowControl(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_TIME + i); - GUIControl.SetControlLabel(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_LINE + i, _lines[i]); - GUIControl.SetControlLabel(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_LINE_DONE + i, + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE + i); + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE_DONE + i); + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_TIME + i); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE + i, _lines[i]); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE_DONE + i, _lines[i]); - GUIControl.SetControlLabel(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_TIME + i, "[xx:xx.xx]"); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_TIME + i, "[xx:xx.xx]"); } } catch @@ -397,20 +404,23 @@ } else { + resetGUI(_selectedScreen); _StatusText = "No music file is playing"; - GUIControl.SetControlLabel(GetID, (int) GUI_General_Controls.CONTROL_LBStatus, _StatusText); + GUIControl.SetControlLabel(GetID, (int)GUI_General_Controls.CONTROL_LBStatus, _StatusText); } } private void LoadSettings() { _newTrack = true; - _SearchingState = (int) SEARCH_STATE.NOT_SEARCHING; + _SearchingState = (int)SEARCH_STATE.NOT_SEARCHING; _LyricsToWriteToTag = new List<string[]>(); resetGUI(_selectedScreen); + + using (Settings xmlreader = new Settings("MediaPortal.xml")) { _UseID3 = xmlreader.GetValueAsBool("musicfiles", "showid3", true); @@ -463,7 +473,7 @@ string translationString = (xmlreader.GetValueAsString("myLyrics", "translationLanguage", "English (en)")); - string[] strings = translationString.Split(new string[1] {"("}, StringSplitOptions.None); + string[] strings = translationString.Split(new string[1] { "(" }, StringSplitOptions.None); _translationLanguage = strings[0].Trim(); _translationLanguageCode = strings[1].Replace(")", string.Empty); @@ -479,15 +489,15 @@ if (_useAutoScrollAsDefault) { - CONTROL_LYRIC_SELECTED = (int) GUI_Lyrics_Controls.CONTROL_Lyric_Scroll; + CONTROL_LYRIC_SELECTED = (int)GUI_Lyrics_Controls.CONTROL_Lyric_Scroll; - GUIControl.HideControl(GetID, (int) GUI_Lyrics_Controls.CONTROL_Lyric); + GUIControl.HideControl(GetID, (int)GUI_Lyrics_Controls.CONTROL_Lyric); } else { - CONTROL_LYRIC_SELECTED = (int) GUI_Lyrics_Controls.CONTROL_Lyric; + CONTROL_LYRIC_SELECTED = (int)GUI_Lyrics_Controls.CONTROL_Lyric; - GUIControl.HideControl(GetID, (int) GUI_Lyrics_Controls.CONTROL_Lyric_Scroll); + GUIControl.HideControl(GetID, (int)GUI_Lyrics_Controls.CONTROL_Lyric_Scroll); } if (string.IsNullOrEmpty(_guidString)) @@ -542,7 +552,7 @@ sitesToSearch.Add("LyricsPluginSite"); } - _LyricSitesTosearch = (string[]) sitesToSearch.ToArray(typeof (string)); + _LyricSitesTosearch = (string[])sitesToSearch.ToArray(typeof(string)); // Deserialize lyrics and marked database, and save references in LyricsDB try @@ -550,17 +560,17 @@ string path = Config.GetFile(Config.Dir.Database, MLyricsDbName); FileStream fs = new FileStream(path, FileMode.Open); BinaryFormatter bf = new BinaryFormatter(); - LyricsDb = (LyricsDatabase) bf.Deserialize(fs); + LyricsDb = (LyricsDatabase)bf.Deserialize(fs); fs.Close(); path = Config.GetFile(Config.Dir.Database, MLyricsMarkedDbName); fs = new FileStream(path, FileMode.Open); - LyricsMarkedDb = (LyricsDatabase) bf.Deserialize(fs); + LyricsMarkedDb = (LyricsDatabase)bf.Deserialize(fs); fs.Close(); } catch { - GUIDialogOK dlg = (GUIDialogOK) GUIWindowManager.GetWindow((int) Window.WINDOW_DIALOG_OK); + GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); dlg.SetHeading("No lyric database found"); dlg.SetLine(1, "Please run the MyLyrics configuration"); dlg.SetLine(2, "before running the plugin."); @@ -574,6 +584,8 @@ { LoadSettings(); + GUIPropertyManager.OnPropertyChanged += trackChangeHandler; + //_OkToCallPreviousMenu = false; base.OnPageLoad(); @@ -581,7 +593,7 @@ if (_ImageChangeTimer == null) { _ImageChangeTimer = new Timer(); - _ImageChangeTimer.Interval = 15*1000; + _ImageChangeTimer.Interval = 15 * 1000; _ImageChangeTimer.Elapsed += OnImageTimerTickEvent; _ImageChangeTimer.Start(); } @@ -599,7 +611,7 @@ { StopThread(); resetAll(); - resetGUI((int) MyLyricsSettings.Screen.LYRICS); + resetGUI((int)MyLyricsSettings.Screen.LYRICS); GUIGraphicsContext.ScrollSpeedVertical = _startingScrollSpeedVertical; @@ -662,14 +674,14 @@ } _lyricsFound = false; - if (_selectedScreen != (int) MyLyricsSettings.Screen.LRC_EDITOR) + if (_selectedScreen != (int)MyLyricsSettings.Screen.LRC_EDITOR) { - resetGUI((int) MyLyricsSettings.Screen.LRC_EDITOR); + resetGUI((int)MyLyricsSettings.Screen.LRC_EDITOR); } else { // parameter could be anything but LRC_EDITOR. Will find correct type when running findLyric(). - resetGUI((int) MyLyricsSettings.Screen.LYRICS); + resetGUI((int)MyLyricsSettings.Screen.LYRICS); } _newTrack = true; @@ -692,27 +704,27 @@ } else if (action.m_key.KeyChar.Equals(102)) // 'F' { - if (_selectedScreen != (int) MyLyricsSettings.Screen.LRC_PICK - && _selectedScreen != (int) MyLyricsSettings.Screen.LRC_EDITOR) + if (_selectedScreen != (int)MyLyricsSettings.Screen.LRC_PICK + && _selectedScreen != (int)MyLyricsSettings.Screen.LRC_EDITOR) { - if (_SearchType == (int) SEARCH_TYPES.BOTH_LRCS_AND_LYRICS) + if (_SearchType == (int)SEARCH_TYPES.BOTH_LRCS_AND_LYRICS) { - if (_selectedScreen == (int) MyLyricsSettings.Screen.LRC) + if (_selectedScreen == (int)MyLyricsSettings.Screen.LRC) { - _SearchType = (int) SEARCH_TYPES.ONLY_LYRICS; + _SearchType = (int)SEARCH_TYPES.ONLY_LYRICS; } else { - _SearchType = (int) SEARCH_TYPES.ONLY_LRCS; + _SearchType = (int)SEARCH_TYPES.ONLY_LRCS; } } - else if (_SearchType == (int) SEARCH_TYPES.ONLY_LRCS) + else if (_SearchType == (int)SEARCH_TYPES.ONLY_LRCS) { - _SearchType = (int) SEARCH_TYPES.ONLY_LYRICS; + _SearchType = (int)SEARCH_TYPES.ONLY_LYRICS; } else { - _SearchType = (int) SEARCH_TYPES.ONLY_LRCS; + _SearchType = (int)SEARCH_TYPES.ONLY_LRCS; } _newTrack = true; @@ -730,7 +742,7 @@ if (noOfRows <= _LrcTable.Rows.Count) { string status = string.Format("LRC {0} of {1} shown", noOfRows, _LrcTable.Rows.Count); - GUIControl.SetControlLabel(GetID, (int) GUI_LRC_Controls.CONTROL_LRCPICK_STATUS, status); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_LRCPICK_STATUS, status); _LyricText = _LrcTable.Rows[index]["Lyrics"] as string; _SimpleLrc = new SimpleLRC(null, null, _LyricText); @@ -743,6 +755,7 @@ } else if (action.m_key.KeyChar.Equals(98)) // 'B' (stop playing media) { + resetLrcFields(); resetGUI(_selectedScreen); } break; @@ -769,7 +782,7 @@ private void ShowLrcPick() { - if (_selectedScreen != (int) MyLyricsSettings.Screen.LRC_PICK) + if (_selectedScreen != (int)MyLyricsSettings.Screen.LRC_PICK) { LrcFinder lrcFinder = new LrcFinder(); _LrcTable = lrcFinder.FindLRCs(_artist, _title); @@ -792,21 +805,21 @@ status = string.Format("LRC {0} of {1} shown", "1", _LrcTable.Rows.Count); } - GUIControl.SetControlLabel(GetID, (int) GUI_LRC_Controls.CONTROL_LRCPICK_STATUS, status); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_LRCPICK_STATUS, status); } else if (_LrcTable == null) { - resetGUI((int) MyLyricsSettings.Screen.LRC_PICK); + resetGUI((int)MyLyricsSettings.Screen.LRC_PICK); string status = "LrcFinder could not be reached..."; - GUIControl.SetControlLabel(GetID, (int) GUI_LRC_Controls.CONTROL_LRCPICK_STATUS, status); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_LRCPICK_STATUS, status); } else { //resetGUI((int)MyLyricsSettings.Screen.LRC_PICK); string status = "No LRC found..."; - GUIControl.SetControlLabel(GetID, (int) GUI_LRC_Controls.CONTROL_LRCPICK_STATUS, status); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_LRCPICK_STATUS, status); //string lyricInfo = "Press the 'P' key to return"; //GUIControl.SetControlLabel(GetID, CONTROL_LYRIC_SELECTED, lyricInfo); @@ -823,7 +836,7 @@ _LrcTable = null; _newTrack = true; - _SearchingState = (int) SEARCH_STATE.NOT_SEARCHING; + _SearchingState = (int)SEARCH_STATE.NOT_SEARCHING; Process(); } @@ -832,7 +845,7 @@ protected override void OnShowContextMenu() { - GUIDialogMenu dlg = (GUIDialogMenu) GUIWindowManager.GetWindow((int) Window.WINDOW_DIALOG_MENU); + GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; @@ -847,7 +860,7 @@ string translateLabelString = "Translate to " + _translationLanguage.ToLower(); dlg.Add(translateLabelString); - if (_selectedScreen == (int) MyLyricsSettings.Screen.LRC_PICK) + if (_selectedScreen == (int)MyLyricsSettings.Screen.LRC_PICK) { dlg.Add("Use picked LRC"); } @@ -856,7 +869,7 @@ dlg.Add("Pick LRC"); } - if (CONTROL_LYRIC_SELECTED == (int) GUI_Lyrics_Controls.CONTROL_Lyric) + if (CONTROL_LYRIC_SELECTED == (int)GUI_Lyrics_Controls.CONTROL_Lyric) { dlg.Add("Show scrolling lyric"); } @@ -874,18 +887,18 @@ switch (dlg.SelectedLabelText) { case "Find LRC": - _SearchType = (int) SEARCH_TYPES.ONLY_LRCS; + _SearchType = (int)SEARCH_TYPES.ONLY_LRCS; - _selectedScreen = (int) MyLyricsSettings.Screen.LRC; + _selectedScreen = (int)MyLyricsSettings.Screen.LRC; resetGUI(_selectedScreen); _newTrack = true; break; case "Find lyric": - _SearchType = (int) SEARCH_TYPES.ONLY_LYRICS; + _SearchType = (int)SEARCH_TYPES.ONLY_LYRICS; - _selectedScreen = (int) MyLyricsSettings.Screen.LYRICS; + _selectedScreen = (int)MyLyricsSettings.Screen.LYRICS; resetGUI(_selectedScreen); _newTrack = true; @@ -895,7 +908,7 @@ // Don't use a stream to create a LRC if (g_Player.IsRadio) { - GUIDialogOK dlg2 = (GUIDialogOK) GUIWindowManager.GetWindow((int) Window.WINDOW_DIALOG_OK); + GUIDialogOK dlg2 = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); dlg2.SetHeading("LRC editor error"); dlg2.SetLine(1, "You cannot tag a streaming"); dlg2.SetLine(2, "media due to inproper timestamps."); @@ -904,13 +917,13 @@ return; } - GUIControl.HideControl(GetID, (int) GUI_Lyrics_Controls.CONTROL_Lyric_Scroll); - CONTROL_LYRIC_SELECTED = (int) GUI_Lyrics_Controls.CONTROL_Lyric; + GUIControl.HideControl(GetID, (int)GUI_Lyrics_Controls.CONTROL_Lyric_Scroll); + CONTROL_LYRIC_SELECTED = (int)GUI_Lyrics_Controls.CONTROL_Lyric; //_lyricsFound = false; - if (_selectedScreen != (int) MyLyricsSettings.Screen.LRC_EDITOR) + if (_selectedScreen != (int)MyLyricsSettings.Screen.LRC_EDITOR) { - resetGUI((int) MyLyricsSettings.Screen.LRC_EDITOR); + resetGUI((int)MyLyricsSettings.Screen.LRC_EDITOR); } //_newTrack = true; @@ -929,24 +942,24 @@ case "Show scrolling lyric": case "Show static lyric": - _SearchType = (int) SEARCH_TYPES.ONLY_LYRICS; + _SearchType = (int)SEARCH_TYPES.ONLY_LYRICS; - _selectedScreen = (int) MyLyricsSettings.Screen.LYRICS; + _selectedScreen = (int)MyLyricsSettings.Screen.LYRICS; resetGUI(_selectedScreen); _newTrack = true; - if (CONTROL_LYRIC_SELECTED == (int) GUI_Lyrics_Controls.CONTROL_Lyric) + if (CONTROL_LYRIC_SELECTED == (int)GUI_Lyrics_Controls.CONTROL_Lyric) { - CONTROL_LYRIC_SELECTED = (int) GUI_Lyrics_Controls.CONTROL_Lyric_Scroll; - GUIControl.ShowControl(GetID, (int) GUI_Lyrics_Controls.CONTROL_Lyric_Scroll); - GUIControl.HideControl(GetID, (int) GUI_Lyrics_Controls.CONTROL_Lyric); + CONTROL_LYRIC_SELECTED = (int)GUI_Lyrics_Controls.CONTROL_Lyric_Scroll; + GUIControl.ShowControl(GetID, (int)GUI_Lyrics_Controls.CONTROL_Lyric_Scroll); + GUIControl.HideControl(GetID, (int)GUI_Lyrics_Controls.CONTROL_Lyric); } else { - CONTROL_LYRIC_SELECTED = (int) GUI_Lyrics_Controls.CONTROL_Lyric; - GUIControl.HideControl(GetID, (int) GUI_Lyrics_Controls.CONTROL_Lyric_Scroll); - GUIControl.ShowControl(GetID, (int) GUI_Lyrics_Controls.CONTROL_Lyric); + CONTROL_LYRIC_SELECTED = (int)GUI_Lyrics_Controls.CONTROL_Lyric; + GUIControl.HideControl(GetID, (int)GUI_Lyrics_Controls.CONTROL_Lyric_Scroll); + GUIControl.ShowControl(GetID, (int)GUI_Lyrics_Controls.CONTROL_Lyric); } break; @@ -957,7 +970,7 @@ TranslateProvider.TranslateProvider translate = null; _StatusText = string.Empty; - GUIControl.SetControlLabel(GetID, (int) GUI_General_Controls.CONTROL_LBStatus, _StatusText); + GUIControl.SetControlLabel(GetID, (int)GUI_General_Controls.CONTROL_LBStatus, _StatusText); string lyricToTranslate = string.Empty; @@ -977,7 +990,7 @@ } catch (FileNotFoundException ex) { - GUIDialogOK dlg3 = (GUIDialogOK) GUIWindowManager.GetWindow((int) Window.WINDOW_DIALOG_OK); + GUIDialogOK dlg3 = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); dlg3.SetHeading("File not found"); dlg3.SetLine(1, "The TranslateProvider.dll assembly"); dlg3.SetLine(2, "could not be found."); @@ -994,9 +1007,9 @@ translation = MediaPortalUtil.MakePlainLyricPerfectToShow(translation); - resetGUI((int) MyLyricsSettings.Screen.LYRICS); + resetGUI((int)MyLyricsSettings.Screen.LYRICS); GUIControl.SetControlLabel(GetID, CONTROL_LYRIC_SELECTED, translation); - GUIControl.SetControlLabel(GetID, (int) GUI_General_Controls.CONTROL_TITLE, + GUIControl.SetControlLabel(GetID, (int)GUI_General_Controls.CONTROL_TITLE, string.Format("{0} translation", _translationLanguage)); GUIControl.FocusControl(GetID, CONTROL_LYRIC_SELECTED); @@ -1007,6 +1020,9 @@ //event driven handler to detect track change private void trackChangeHandler(string tag2, string value) { + if (tag2.Contains("#percentage") || tag2.Contains("#currentplaytime") || tag2.Contains("#currentremaining")) + return; + if (tag2.Equals("#Play.Current.Track")) // track has changed { if (value.Length != 0) // additional check @@ -1016,8 +1032,8 @@ StopThread(); resetAll(); _newTrack = true; - _SearchType = (int) SEARCH_TYPES.BOTH_LRCS_AND_LYRICS; - _SearchingState = (int) SEARCH_STATE.NOT_SEARCHING; + _SearchType = (int)SEARCH_TYPES.BOTH_LRCS_AND_LYRICS; + _SearchingState = (int)SEARCH_STATE.NOT_SEARCHING; Process(); } else @@ -1030,7 +1046,7 @@ resetGUI(_selectedScreen); _StatusText = "No music file playing"; - GUIControl.SetControlLabel(GetID, (int) GUI_General_Controls.CONTROL_LBStatus, _StatusText); + GUIControl.SetControlLabel(GetID, (int)GUI_General_Controls.CONTROL_LBStatus, _StatusText); } } else if (g_Player.IsRadio) @@ -1042,7 +1058,7 @@ || string.IsNullOrEmpty(GUIPropertyManager.GetProperty("#Play.Current.Title"))) { _StatusText = "Stream info not complete"; - GUIControl.SetControlLabel(GetID, (int) GUI_General_Controls.CONTROL_LBStatus, _StatusText); + GUIControl.SetControlLabel(GetID, (int)GUI_General_Controls.CONTROL_LBStatus, _StatusText); } else if (!g_Player.CurrentFile.Equals(_LastStreamFile) || !newArtist.Equals(_artist) || !newTitle.Equals(_title)) @@ -1051,8 +1067,8 @@ StopThread(); resetAll(); - _SearchType = (int) SEARCH_TYPES.BOTH_LRCS_AND_LYRICS; - _SearchingState = (int) SEARCH_STATE.NOT_SEARCHING; + _SearchType = (int)SEARCH_TYPES.BOTH_LRCS_AND_LYRICS; + _SearchingState = (int)SEARCH_STATE.NOT_SEARCHING; _LastStreamFile = g_Player.CurrentFile; @@ -1087,7 +1103,7 @@ } /// <summary> - /// findLyric searches for a lyric related to the given tag. + /// FindLrc searches for a lyric related to the given tag. /// </summary> private bool FindLrc() { @@ -1096,7 +1112,7 @@ GUIControl.ClearControl(GetID, CONTROL_LYRIC_SELECTED); GUIControl.SetControlLabel(GetID, CONTROL_LYRIC_SELECTED, ""); - resetGUI((int) MyLyricsSettings.Screen.LRC); + resetGUI((int)MyLyricsSettings.Screen.LRC); if ((_CurrentTrackTag != null && _CurrentTrackTag.Artist != "") || g_Player.IsRadio) { @@ -1118,10 +1134,10 @@ 6) Search for lyric */ // (1 of 2) Search LRCS - if (_SearchType != (int) SEARCH_TYPES.ONLY_LYRICS) + if (_SearchType != (int)SEARCH_TYPES.ONLY_LYRICS) { _StatusText = "Searching for a matching LRC..."; - GUIControl.SetControlLabel(GetID, (int) GUI_General_Controls.CONTROL_LBStatus, _StatusText); + GUIControl.SetControlLabel(GetID, (int)GUI_General_Controls.CONTROL_LBStatus, _StatusText); #region 1) LRC in music tag @@ -1168,7 +1184,7 @@ { _lyricsFound = false; - _lc = new LyricsController(this, _EventStopThread, new string[1] {"LrcFinder"}, false, false, + _lc = new LyricsController(this, _EventStopThread, new string[1] { "LrcFinder" }, false, false, _Find, _Replace); // create worker thread instance @@ -1186,7 +1202,7 @@ else { _StatusText = "No matching LRC found"; - GUIControl.SetControlLabel(GetID, (int) GUI_General_Controls.CONTROL_LBStatus, _StatusText); + GUIControl.SetControlLabel(GetID, (int)GUI_General_Controls.CONTROL_LBStatus, _StatusText); } #endregion @@ -1222,14 +1238,14 @@ lyricText = LyricsDb[DatabaseUtil.CorrectKeyFormat(_artist, _title)].Lyrics; } - if (_SearchType != (int) SEARCH_TYPES.ONLY_LRCS) + if (_SearchType != (int)SEARCH_TYPES.ONLY_LRCS) { #region 4) Lyric in music tag if (_AutomaticReadFromMusicTag && g_Player.IsRadio == false && _CurrentTrackTag != null && _CurrentTrackTag.Lyrics.Length != 0 && - !((_SearchType == (int) SEARCH_TYPES.ONLY_LYRICS) && + !((_SearchType == (int)SEARCH_TYPES.ONLY_LYRICS) && new SimpleLRC(_artist, _title, _CurrentTrackTag.Lyrics).IsValid)) { string lyric = LyricUtil.FixLyrics(_CurrentTrackTag.Lyrics); @@ -1244,22 +1260,22 @@ #region 5) Lyric in music database if (lyricText.Length != 0 && - !((_SearchType == (int) SEARCH_TYPES.ONLY_LYRICS) && _CurrentTrackTag != null && + !((_SearchType == (int)SEARCH_TYPES.ONLY_LYRICS) && _CurrentTrackTag != null && new SimpleLRC(_artist, _title, _CurrentTrackTag.Lyrics).IsValid)) { - LyricFound = new Object[] {lyricText, _artist, _title, "lyrics database"}; + LyricFound = new Object[] { lyricText, _artist, _title, "lyrics database" }; return true; } - #endregion + #endregion - #region 6) Search the Internet for a lyric + #region 6) Search the Internet for a lyric else if (_LyricSitesTosearch.Length > 0) { _StatusText = "Searching for a matching lyric..."; - GUIControl.SetControlLabel(GetID, (int) GUI_General_Controls.CONTROL_LBStatus, _StatusText); + GUIControl.SetControlLabel(GetID, (int)GUI_General_Controls.CONTROL_LBStatus, _StatusText); - resetGUI((int) MyLyricsSettings.Screen.LYRICS); + resetGUI((int)MyLyricsSettings.Screen.LYRICS); _lyricsFound = false; @@ -1293,9 +1309,11 @@ } else { + resetGUI(_selectedScreen); + resetLrcFields(); _TrackText = ""; _StatusText = "No music file playing"; - GUIControl.SetControlLabel(GetID, (int) GUI_General_Controls.CONTROL_LBStatus, _StatusText); + GUIControl.SetControlLabel(GetID, (int)GUI_General_Controls.CONTROL_LBStatus, _StatusText); return false; } } @@ -1317,33 +1335,33 @@ if (showLrcPickScreen) { - resetGUI((int) MyLyricsSettings.Screen.LRC_PICK); + resetGUI((int)MyLyricsSettings.Screen.LRC_PICK); } else { - resetGUI((int) MyLyricsSettings.Screen.LRC); + resetGUI((int)MyLyricsSettings.Screen.LRC); } _StatusText = ""; - GUIControl.SetControlLabel(GetID, (int) GUI_General_Controls.CONTROL_LBStatus, _StatusText); + GUIControl.SetControlLabel(GetID, (int)GUI_General_Controls.CONTROL_LBStatus, _StatusText); _LyricText = lyricText; try { - for (int i = _tagRoundFinished*_TAG_IN_ROUND; i < (_tagRoundFinished + 1)*_TAG_IN_ROUND; i++) + for (int i = _tagRoundFinished * _TAG_IN_ROUND; i < (_tagRoundFinished + 1) * _TAG_IN_ROUND; i++) { - ShowLrcLine((int) GUI_LRC_Controls.CONTROL_VIEW_LINE + i, _lines[i]); - ShowLrcLine((int) GUI_LRC_Controls.CONTROL_VIEW_LINE_DONE + i, _lines[i]); + ShowLrcLine((int)GUI_LRC_Controls.CONTROL_VIEW_LINE + i, _lines[i]); + ShowLrcLine((int)GUI_LRC_Controls.CONTROL_VIEW_LINE_DONE + i, _lines[i]); } - if (_selectedScreen == (int) MyLyricsSettings.Screen.LRC_PICK) + if (_selectedScreen == (int)MyLyricsSettings.Screen.LRC_PICK) { - for (int i = _tagRoundFinished*_TAG_IN_ROUND; i < (_tagRoundFinished + 1)*_TAG_IN_ROUND; i++) + for (int i = _tagRoundFinished * _TAG_IN_ROUND; i < (_tagRoundFinished + 1) * _TAG_IN_ROUND; i++) { SimpleLRCTimeAndLine currentLine = _LrcTimeCollection[i]; - GUIControl.ShowControl(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_TIME + i); - GUIControl.SetControlLabel(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_TIME + i, + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_TIME + i); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_TIME + i, currentLine.TimeString); } } @@ -1355,7 +1373,7 @@ private void TagLine() { - if (_alreadyValidLRC == false && _selectedScreen == (int) MyLyricsSettings.Screen.LRC_EDITOR) + if (_alreadyValidLRC == false && _selectedScreen == (int)MyLyricsSettings.Screen.LRC_EDITOR) { if (_Stopwatch == null) return; @@ -1368,38 +1386,38 @@ ? _Stopwatch.ElapsedMilliseconds.ToString().Substring(0, 2) : _Stopwatch.ElapsedMilliseconds + "0") + "]"; _lines[_LRCLinesTotal] = time + _lines[_LRCLinesTotal]; - GUIControl.SetControlLabel(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_TIME + _currentLRCLineIndex, + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_TIME + nextLRCLineIndex, time); - GUIControl.HideControl(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_LINE + _currentLRCLineIndex); - GUIControl.ShowControl(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_LINE_DONE + _currentLRCLineIndex); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE + nextLRCLineIndex); + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE_DONE + nextLRCLineIndex); } if (++_LRCLinesTotal < _lines.Length) { // If a new round has to start - if (++_currentLRCLineIndex == _TAG_IN_ROUND) + if (++nextLRCLineIndex == _TAG_IN_ROUND) { - _currentLRCLineIndex = 0; + nextLRCLineIndex = 0; ++_tagRoundFinished; for (int i = 0; i < _TAG_IN_ROUND; i++) { - GUIControl.SetControlLabel(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_TIME + i, ""); - GUIControl.SetControlLabel(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_LINE + i, ""); - GUIControl.SetControlLabel(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_LINE_DONE + i, ""); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_TIME + i, ""); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE + i, ""); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE_DONE + i, ""); } try { for (int i = 0; i < _TAG_IN_ROUND && _LRCLinesTotal + i < _lines.Length; i++) { - GUIControl.SetControlLabel(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_LINE + i, - _lines[_tagRoundFinished*_TAG_IN_ROUND + i]); - GUIControl.SetControlLabel(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_LINE_DONE + i, - _lines[_tagRoundFinished*_TAG_IN_ROUND + i]); - GUIControl.ShowControl(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_LINE + i); - GUIControl.SetControlLabel(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_TIME + i, + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE + i, + _lines[_tagRoundFinished * _TAG_IN_ROUND + i]); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE_DONE + i, + _lines[_tagRoundFinished * _TAG_IN_ROUND + i]); + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE + i); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_TIME + i, "[xx:xx.xx]"); } } @@ -1449,7 +1467,7 @@ SaveLyricToTagLists(_CurrentTrackTag.FileName, _LyricText); } - _selectedScreen = (int) MyLyricsSettings.Screen.LRC; + _selectedScreen = (int)MyLyricsSettings.Screen.LRC; ShowLyricOnScreen(_LyricText, "MediaPortal"); // Upload LRC to LrcFinder if user has accepted in configuration @@ -1460,7 +1478,7 @@ else if (!_confirmedNoUploadLrcToLrcFinder) { GUIDialogYesNo dlgYesNo = - (GUIDialogYesNo) GUIWindowManager.GetWindow((int) Window.WINDOW_DIALOG_YES_NO); + (GUIDialogYesNo)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_YES_NO); if (dlgYesNo != null) { dlgYesNo.SetHeading("Upload to LRCFinder?"); @@ -1505,12 +1523,12 @@ if (lrcUploaded) { string status = "Your LRC was successfully uploaded"; - GUIControl.SetControlLabel(GetID, (int) GUI_LRC_Controls.CONTROL_LRCPICK_STATUS, status); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_LRCPICK_STATUS, status); } else { string status = "LrcFinder could not be reached..."; - GUIControl.SetControlLabel(GetID, (int) GUI_LRC_Controls.CONTROL_LRCPICK_STATUS, status); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_LRCPICK_STATUS, status); } } @@ -1527,23 +1545,23 @@ string lastTimeStampTemp = _lines[_LRCLinesTotal].Substring(0, 9); _lines[_LRCLinesTotal] = _lines[_LRCLinesTotal].Substring(9); - if (--_currentLRCLineIndex < 0) + if (--nextLRCLineIndex < 0) { - _currentLRCLineIndex = _TAG_IN_ROUND - 1; + nextLRCLineIndex = _TAG_IN_ROUND - 1; --_tagRoundFinished; try { for (int i = 0; i < _TAG_IN_ROUND; i++) { - GUIControl.SetControlLabel(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_TIME + i, - _lines[_tagRoundFinished*_TAG_IN_ROUND + i].Substring(0, 9)); - GUIControl.SetControlLabel(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_LINE + i, - _lines[_tagRoundFinished*_TAG_IN_ROUND + i].Substring(9)); - GUIControl.SetControlLabel(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_LINE_DONE + i, - _lines[_tagRoundFinished*_TAG_IN_ROUND + i].Substring(9)); - GUIControl.ShowControl(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_LINE_DONE + i); - GUIControl.HideControl(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_LINE + i); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_TIME + i, + _lines[_tagRoundFinished * _TAG_IN_ROUND + i].Substring(0, 9)); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE + i, + _lines[_tagRoundFinished * _TAG_IN_ROUND + i].Substring(9)); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE_DONE + i, + _lines[_tagRoundFinished * _TAG_IN_ROUND + i].Substring(9)); + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE_DONE + i); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE + i); } } catch @@ -1551,16 +1569,16 @@ ; } - GUIControl.ShowControl(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_LINE + _currentLRCLineIndex); - GUIControl.HideControl(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_LINE_DONE + _currentLRCLineIndex); - GUIControl.SetControlLabel(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_TIME + _currentLRCLineIndex, + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE + nextLRCLineIndex); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE_DONE + nextLRCLineIndex); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_TIME + nextLRCLineIndex, "[xx:xx.xx]"); } else { - GUIControl.ShowControl(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_LINE + _currentLRCLineIndex); - GUIControl.HideControl(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_LINE_DONE + _currentLRCLineIndex); - GUIControl.SetControlLabel(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_TIME + _currentLRCLineIndex, + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE + nextLRCLineIndex); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE_DONE + nextLRCLineIndex); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_TIME + nextLRCLineIndex, "[xx:xx.xx]"); } } @@ -1570,15 +1588,15 @@ { if (_LrcTimeCollection != null) { - int trackTime = (int) (g_Player.CurrentPosition*1000); - _currentLRCLineIndex = _LrcTimeCollection.GetSimpleLRCTimeAndLineIndex(trackTime); + int trackTime = (int)(g_Player.CurrentPosition * 1000); + nextLRCLineIndex = _LrcTimeCollection.GetSimpleLRCTimeAndLineIndex(trackTime); - SimpleLRCTimeAndLine currentLine = _LrcTimeCollection[_currentLRCLineIndex]; + SimpleLRCTimeAndLine currentLine = _LrcTimeCollection[nextLRCLineIndex]; - _tagRoundFinished = _currentLRCLineIndex/_TAG_IN_ROUND; - int localIndex = (_currentLRCLineIndex%_TAG_IN_ROUND); + _tagRoundFinished = nextLRCLineIndex / _TAG_IN_ROUND; + int localIndex = (nextLRCLineIndex % _TAG_IN_ROUND); - if (_currentLRCLineIndex == _LrcTimeCollection.Count - 1) + if (nextLRCLineIndex == _LrcTimeCollection.Count - 1) { if (currentLine.Time - trackTime < 500) { @@ -1586,29 +1604,74 @@ } } + #region Show LRC lines in LRC mini labels + + int currentLRCLineIndex = nextLRCLineIndex > 0 ? nextLRCLineIndex - 1 : 0; + + if (_LrcTimeCollection[nextLRCLineIndex].Time < trackTime) + { + ++currentLRCLineIndex; + } + + + // 1. The two previous lines + if (currentLRCLineIndex >= 2) + { + ShowLrcLine((int)GUI_LRC_Controls.CONTROL_MINI_VIEW_LINE + 0, _lines[currentLRCLineIndex - 2]); + } + if (currentLRCLineIndex >= 1) + { + ShowLrcLine((int)GUI_LRC_Controls.CONTROL_MINI_VIEW_LINE + 1, _lines[currentLRCLineIndex - 1]); + } + + // 2. The current line + ShowLrcLine((int)GUI_LRC_Controls.CONTROL_MINI_VIEW_LINE + 2, _lines[currentLRCLineIndex + 0]); + + // 3. The two future lines + // If last, then show empty lines for fourth and fifth label (showing the future LRC lines) + if (currentLRCLineIndex + 1 == _LrcTimeCollection.Count) + { + ShowLrcLine((int)GUI_LRC_Controls.CONTROL_MINI_VIEW_LINE + 3, string.Empty); + ShowLrcLine((int)GUI_LRC_Controls.CONTROL_MINI_VIEW_LINE + 4, string.Empty); + } + // If second last then clear the last label (only one future LRC lines left) + else if (currentLRCLineIndex + 2 == _LrcTimeCollection.Count) + { + ShowLrcLine((int)GUI_LRC_Controls.CONTROL_MINI_VIEW_LINE + 3, _lines[currentLRCLineIndex + 1]); + ShowLrcLine((int)GUI_LRC_Controls.CONTROL_MINI_VIEW_LINE + 4, string.Empty); + } + else + { + ShowLrcLine((int)GUI_LRC_Controls.CONTROL_MINI_VIEW_LINE + 3, _lines[currentLRCLineIndex + 1]); + ShowLrcLine((int)GUI_LRC_Controls.CONTROL_MINI_VIEW_LINE + 4, _lines[currentLRCLineIndex + 2]); + } + + #endregion + + if (_tagRoundFinished > 0 && localIndex == 0) { for (int i = 0; i < _TAG_IN_ROUND; i++) { - GUIControl.ShowControl(GetID, (int) GUI_LRC_Controls.CONTROL_VIEW_LINE_DONE + i); + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_VIEW_LINE_DONE + i); } } else { for (int i = 0; i < _TAG_IN_ROUND; i++) { - GUIControl.SetControlLabel(GetID, (int) GUI_LRC_Controls.CONTROL_VIEW_LINE + i, ""); - GUIControl.SetControlLabel(GetID, (int) GUI_LRC_Controls.CONTROL_VIEW_LINE_DONE + i, ""); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_VIEW_LINE + i, ""); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_VIEW_LINE_DONE + i, ""); } - if (_selectedScreen == (int) MyLyricsSettings.Screen.LRC_PICK) + if (_selectedScreen == (int)MyLyricsSettings.Screen.LRC_PICK) { for (int i = 0; i < _TAG_IN_ROUND; i++) { SimpleLRCTimeAndLine currentLineTime = - _LrcTimeCollection[_tagRoundFinished*_TAG_IN_ROUND + i]; - GUIControl.ShowControl(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_TIME + i); - GUIControl.SetControlLabel(GetID, (int) GUI_LRC_Controls.CONTROL_EDIT_TIME + i, + _LrcTimeCollection[_tagRoundFinished * _TAG_IN_ROUND + i]; + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_TIME + i); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_TIME + i, (currentLineTime != null ? currentLineTime.TimeString : string.Empty)); @@ -1619,11 +1682,11 @@ { for (int i = 0; i < _TAG_IN_ROUND; i++) { - ShowLrcLine((int) GUI_LRC_Controls.CONTROL_VIEW_LINE + i, - _lines[_tagRoundFinished*_TAG_IN_ROUND + i]); - GUIControl.HideControl(GetID, (int) GUI_LRC_Controls.CONTROL_VIEW_LINE_DONE + i); - ShowLrcLine((int) GUI_LRC_Controls.CONTROL_VIEW_LINE_DONE + i, - _lines[_tagRoundFinished*_TAG_IN_ROUND + i]); + ShowLrcLine((int)GUI_LRC_Controls.CONTROL_VIEW_LINE + i, + _lines[_tagRoundFinished * _TAG_IN_ROUND + i]); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_VIEW_LINE_DONE + i); + ShowLrcLine((int)GUI_LRC_Controls.CONTROL_VIEW_LINE_DONE + i, + _lines[_tagRoundFinished * _TAG_IN_ROUND + i]); } } catch @@ -1635,7 +1698,7 @@ // Highlight the lines that have been passed in the current interval for (int i = 0; i < localIndex; i++) { - GUIControl.ShowControl(GetID, (int) GUI_LRC_Controls.CONTROL_VIEW_LINE_DONE + i); + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_VIEW_LINE_DONE + i); } } } @@ ... [truncated message content] |