From: <sa...@us...> - 2007-04-16 22:15:32
|
Revision: 336 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=336&view=rev Author: saamand Date: 2007-04-16 15:15:24 -0700 (Mon, 16 Apr 2007) Log Message: ----------- Modified Paths: -------------- trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRC.cs trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRCFormat.cs trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRCTimeAndLine.cs trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRCTimeAndLineCollection.cs trunk/plugins/MyLyrics/LyricsEngine/LyricDiagnostics.cs trunk/plugins/MyLyrics/LyricsEngine/LyricSearch.cs trunk/plugins/MyLyrics/LyricsEngine/LyricUtil.cs trunk/plugins/MyLyrics/LyricsEngine/LyricsController.cs trunk/plugins/MyLyrics/LyricsEngine/LyricsDatabase/LyricsDatabase.cs trunk/plugins/MyLyrics/LyricsEngine/LyricsDatabase/LyricsItem.cs trunk/plugins/MyLyrics/LyricsEngine/LyricsEngine.csproj trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/EvilLabs.cs trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/HotLyrics.cs trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/Lyrics007.cs trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/LyricsOnDemand.cs trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/SeekLyrics.cs trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/Wiki.cs trunk/plugins/MyLyrics/LyricsEngine/Properties/AssemblyInfo.cs trunk/plugins/MyLyrics/LyricsEngine/Setup.cs trunk/plugins/MyLyrics/My Lyrics/Convert/ConvertFromXMLtoLyricsDatabase.cs trunk/plugins/MyLyrics/My Lyrics/DatabaseUtil.cs trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs trunk/plugins/MyLyrics/My Lyrics/MyLyrics.csproj trunk/plugins/MyLyrics/My Lyrics/MyLyricsSettings.cs trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup.cs trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup_AddNewSong.cs trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup_LyricsLibrary.cs trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup_SearchTitleDialog.cs trunk/plugins/MyLyrics/My Lyrics/Properties/AssemblyInfo.cs trunk/plugins/MyLyrics/MyLyric Windows Application/MyLyric Windows Application/Properties/AssemblyInfo.cs trunk/plugins/MyLyrics/MyLyrics.sln trunk/plugins/MyLyrics/MyLyrics.suo Modified: trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRC.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRC.cs 2007-04-16 22:06:02 UTC (rev 335) +++ trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRC.cs 2007-04-16 22:15:24 UTC (rev 336) @@ -3,7 +3,7 @@ using System.Text; using System.IO; -namespace LRC +namespace LyricsEngine.LRC { public class SimpleLRC { @@ -161,21 +161,21 @@ else if ((m = LRC.SimpleLRCFormat.Artist_LineStart_Regex.Match(line)).Success) { artist = line.Substring(m.Index + m.Length); - artist = LyricsEngine.LyricUtil.capatalizeString(artist.Substring(0, artist.LastIndexOf("]"))); + artist = LyricsEngine.LyricUtil.CapatalizeString(artist.Substring(0, artist.LastIndexOf("]"))); return true; } else if ((m = LRC.SimpleLRCFormat.Title_LineStart_Regex.Match(line)).Success) { title = line.Substring(m.Index + m.Length); - title = LyricsEngine.LyricUtil.capatalizeString(title.Substring(0, title.LastIndexOf("]"))); + title = LyricsEngine.LyricUtil.CapatalizeString(title.Substring(0, title.LastIndexOf("]"))); return true; } else if ((m = LRC.SimpleLRCFormat.Album_LineStart_Regex.Match(line)).Success) { album = line.Substring(m.Index + m.Length); - album = LyricsEngine.LyricUtil.capatalizeString((album.Substring(0, album.LastIndexOf("]")))); + album = LyricsEngine.LyricUtil.CapatalizeString((album.Substring(0, album.LastIndexOf("]")))); return true; } else Modified: trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRCFormat.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRCFormat.cs 2007-04-16 22:06:02 UTC (rev 335) +++ trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRCFormat.cs 2007-04-16 22:15:24 UTC (rev 336) @@ -3,7 +3,7 @@ using System.Windows.Forms; using System.Text.RegularExpressions; -namespace LRC +namespace LyricsEngine.LRC { public static class SimpleLRCFormat { Modified: trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRCTimeAndLine.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRCTimeAndLine.cs 2007-04-16 22:06:02 UTC (rev 335) +++ trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRCTimeAndLine.cs 2007-04-16 22:15:24 UTC (rev 336) @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text; -namespace LRC +namespace LyricsEngine.LRC { public class SimpleLRCTimeAndLine : IComparable { Modified: trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRCTimeAndLineCollection.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRCTimeAndLineCollection.cs 2007-04-16 22:06:02 UTC (rev 335) +++ trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRCTimeAndLineCollection.cs 2007-04-16 22:15:24 UTC (rev 336) @@ -2,12 +2,12 @@ using System.Collections; using System.Text; -namespace LRC +namespace LyricsEngine.LRC { public class SimpleLRCTimeAndLineCollection : IEnumerable, ICollection { - private object[] items = null; + private object[] items; public SimpleLRCTimeAndLineCollection(object[] array) { Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricDiagnostics.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricDiagnostics.cs 2007-04-16 22:06:02 UTC (rev 335) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricDiagnostics.cs 2007-04-16 22:15:24 UTC (rev 336) @@ -37,7 +37,7 @@ objTraceListener = new TextWriterTraceListener(objStream); objTraceListener.Filter = new EventTypeFilter(SourceLevels.All); ts.Listeners.Add(objTraceListener); - startTimer(); + StartTimer(); } } @@ -47,7 +47,7 @@ { ts.Flush(); ts.Close(); - stopTimer(); + StopTimer(); objStream.Close(); objStream.Dispose(); @@ -78,18 +78,18 @@ } } - private static void startTimer() + private static void StartTimer() { stopWatch = new Stopwatch(); stopWatch.Start(); } - private static void stopTimer() + private static void StopTimer() { stopWatch.Stop(); } - public static string elapsedTimeString() + public static string ElapsedTimeString() { long time = stopWatch.ElapsedMilliseconds; long sec = time / 1000; Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricSearch.cs =================================================================== (Binary files differ) Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricUtil.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricUtil.cs 2007-04-16 22:06:02 UTC (rev 335) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricUtil.cs 2007-04-16 22:15:24 UTC (rev 336) @@ -6,32 +6,26 @@ { public class LyricUtil { - static string[] parenthesesAndAlike = new string[6] { "(album", "(acoustic", "(live", "(radio", "[", "{" }; static string[] charsToDelete = new string[11] { ".", ",", "&", "'", "!", "\"", "&", "?", "(", ")", "+" /*, "ä", "ö", "ü", "Ä", "Ö", "Ü", "ß" */ }; - // capatalize string and make ready for XML - public static string capatalizeString(string s) + public static string CapatalizeString(string s) { - string[] strings = new String[1] {"\""}; + s = s.Replace("\"", ""); - for (int i = 0; i < strings.Length; i += 1) - { - s = s.Replace(strings[i], ""); - } - - char[] space = new char[] { ' ' }; + char[] space = new char[1] { ' ' }; string[] words = s.Split(space, StringSplitOptions.RemoveEmptyEntries); - string capatalizedTitle = ""; + + StringBuilder result = new StringBuilder(); for (int i = 0; i < words.Length; i++) { - capatalizedTitle += words[i].Substring(0, 1).ToUpper() + (words[i].Length > 1 ? words[i].Substring(1, words[i].Length - 1).ToLower() : "") + " "; + result.Append(words[i].Substring(0, 1).ToUpper() + (words[i].Length > 1 ? words[i].Substring(1, words[i].Length - 1).ToLower() : "") + " "); } - return capatalizedTitle.Trim(); + return result.ToString().Trim(); } - public static string removeFeatComment(string str) + public static string RemoveFeatComment(string str) { int index = str.IndexOf("(Feat"); if (index != -1) @@ -39,7 +33,7 @@ return str; } - public static void trimForParenthesis(ref string str) + public static string TrimForParenthesis(string str) { for (int i = 0; i < parenthesesAndAlike.Length; i++) { @@ -49,17 +43,19 @@ str = str.Substring(0, index).Trim(); } } + return str; } - public static void deleteSpecificChars(ref string str) + public static string DeleteSpecificChars(string str) { for (int i = 0; i < charsToDelete.Length; i++) { str = str.Replace(charsToDelete[i], ""); } + return str; } - public static string changeAnd_and_and(string str) + public static string ChangeAnd_and_and(string str) { string strTemp = str; if (str.Contains("&")) Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricsController.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricsController.cs 2007-04-16 22:06:02 UTC (rev 335) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricsController.cs 2007-04-16 22:15:24 UTC (rev 336) @@ -7,21 +7,10 @@ using System.Threading; using System.IO; using System.Diagnostics; -using LyricsEngineConfig; using LyricsEngine; namespace LyricsEngine { - - #region Public Delegates - // delegates used to call MainForm functions from worker thread - public delegate void Delegate_LC_updateString(String s); - public delegate void Delegate_LC_UpdateStatus(Boolean b1); - public delegate void Delegate_LC_ErrorLog_LyricNotFound(String s); - public delegate void Delegate_LC_WriteFoundLyric(String[] s, String artist, String track); - public delegate void Delegate_LC_ThreadFinished(); - #endregion - public class LyricsController : IDisposable { private ILyricForm m_Form; @@ -32,10 +21,9 @@ private int noOfLyricsFound; private int noOfLyricsNotFound; - private bool m_StopSearches = false; + private bool m_StopSearches; ArrayList threadList = new ArrayList(); - ArrayList suspendedThreadList = new ArrayList(); // Main thread sets this event to stop LyricController ManualResetEvent m_EventStop_LyricController; @@ -44,13 +32,8 @@ ManualResetEvent m_EventStopped_LyricController; private string[] lyricsSites; + internal static bool ALLOW_ALL_TO_SEARCH; - internal static bool ALLOW_ALL_TO_SEARCH = false; - - - - - public LyricsController(ILyricForm mainForm, ManualResetEvent eventStopThread, string[] lyricSites, bool allowAllToSearch) @@ -128,6 +111,9 @@ public void Dispose() { + m_EventStop_LyricController.Close(); + m_EventStopped_LyricController.Close(); + // clean-up operations may be placed here for (int i = 0; i < threadList.Count; i++) { @@ -144,10 +130,10 @@ stillThreadsAlive = true; } } - finishThread("", "", "The search has ended.", ""); + FinishThread("", "", "The search has ended.", ""); } - public void addNewLyricSearch(string artist, string title) + public void AddNewLyricSearch(string artist, string title) { if (lyricsSites.Length > 0) { @@ -168,12 +154,12 @@ - internal void updateString(String message, String site) + internal void UpdateString(String message, String site) { m_Form.UpdateString = new Object[] { message, site }; } - internal void statusUpdate(string artist, string title, string site, bool lyricFound) + internal void StatusUpdate(string artist, string title, string site, bool lyricFound) { //LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Information, 0, LyricDiagnostics.elapsedTimeString() + artist + " - " + title + " - " + site + " - " +lyricFound.ToString() ); if (lyricFound) @@ -187,30 +173,30 @@ if ((noOfLyricsSearched >= noOfLyricsToSearch) && ALLOW_ALL_TO_SEARCH == false) { - finishThread(artist, title, "All songs have been searched!", site); + FinishThread(artist, title, "All songs have been searched!", site); } } - internal void lyricFound(String lyricStrings, String artist, String title, String site) + internal void LyricFound(String lyricStrings, String artist, String title, String site) { if (m_StopSearches == false) { m_Form.LyricFound = new Object[] { lyricStrings, artist, title, site }; - statusUpdate(artist, title, site, true); + StatusUpdate(artist, title, site, true); } } - internal void lyricNotFound(String artist, String title, String message, String site) + internal void LyricNotFound(String artist, String title, String message, String site) { if (m_StopSearches == false) { m_Form.LyricNotFound = new Object[] { artist, title, message, site }; - statusUpdate(artist, title, site, false); + StatusUpdate(artist, title, site, false); } } - public void finishThread(String artist, String title, String message, String site) + public void FinishThread(String artist, String title, String message, String site) { m_StopSearches = true; m_EventStop_LyricController.Set(); Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricsDatabase/LyricsDatabase.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricsDatabase/LyricsDatabase.cs 2007-04-16 22:06:02 UTC (rev 335) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricsDatabase/LyricsDatabase.cs 2007-04-16 22:15:24 UTC (rev 336) @@ -3,7 +3,7 @@ using System.Text; using System.Runtime.Serialization; -namespace MyLyrics +namespace LyricsEngine.Database { [Serializable] public class LyricsDatabase : IDictionary<string, LyricsItem>, ISerializable Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricsDatabase/LyricsItem.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricsDatabase/LyricsItem.cs 2007-04-16 22:06:02 UTC (rev 335) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricsDatabase/LyricsItem.cs 2007-04-16 22:15:24 UTC (rev 336) @@ -3,7 +3,7 @@ using System.Text; using System.Runtime.Serialization; -namespace MyLyrics +namespace LyricsEngine.Database { [Serializable] public class LyricsItem Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricsEngine.csproj =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricsEngine.csproj 2007-04-16 22:06:02 UTC (rev 335) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricsEngine.csproj 2007-04-16 22:15:24 UTC (rev 336) @@ -46,7 +46,7 @@ <Compile Include="LRC\SimpleLRCTimeAndLineCollection.cs" /> <Compile Include="LyricsDatabase\LyricsDatabase.cs" /> <Compile Include="LyricsDatabase\LyricsItem.cs" /> - <Compile Include="LyricsSites\LyricSearch.cs" /> + <Compile Include="LyricSearch.cs" /> <Compile Include="LyricDiagnostics.cs" /> <Compile Include="LyricsSites\HotLyrics.cs" /> <Compile Include="LyricsSites\EvilLabs.cs" /> @@ -57,7 +57,6 @@ <Compile Include="ICommand.cs" /> <Compile Include="ILyricForm.cs" /> <Compile Include="LyricsController.cs" /> - <Compile Include="LyricSiteInfo.cs" /> <EmbeddedResource Include="Properties\Resources.resx"> <Generator>ResXFileCodeGenerator</Generator> <LastGenOutput>Resources.Designer.cs</LastGenOutput> @@ -70,7 +69,6 @@ <DesignTime>True</DesignTime> </Compile> <None Include="app.config" /> - <None Include="ClassDiagram1.cd" /> <None Include="Properties\Settings.settings"> <Generator>SettingsSingleFileGenerator</Generator> <LastGenOutput>Settings.Designer.cs</LastGenOutput> Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/EvilLabs.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/EvilLabs.cs 2007-04-16 22:06:02 UTC (rev 335) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/EvilLabs.cs 2007-04-16 22:15:24 UTC (rev 336) @@ -10,7 +10,7 @@ class EvilLabs { string lyric = ""; - bool complete = false; + bool complete; public string Lyric { @@ -19,13 +19,13 @@ public EvilLabs(string artist, string title) { - if (LyricDiagnostics.TraceSource != null) LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Information, 0, LyricDiagnostics.elapsedTimeString() + "EvilLabs(" + artist + ", " + title + ")"); + if (LyricDiagnostics.TraceSource != null) LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Information, 0, LyricDiagnostics.ElapsedTimeString() + "EvilLabs(" + artist + ", " + title + ")"); - artist = LyricUtil.removeFeatComment(artist); - LyricUtil.trimForParenthesis(ref artist); + artist = LyricUtil.RemoveFeatComment(artist); + artist = LyricUtil.TrimForParenthesis(artist); artist = artist.Replace(" ", "+"); - title = LyricUtil.removeFeatComment(title); - LyricUtil.trimForParenthesis(ref title); + title = LyricUtil.RemoveFeatComment(title); + title = LyricUtil.TrimForParenthesis(title); title = title.Replace(" ", "+"); string urlString = "http://www.evillabs.sk/lyrics/" + artist + "+-+" + title; @@ -44,7 +44,6 @@ private void callbackMethod(object sender, OpenReadCompletedEventArgs e) { bool thisMayBeTheCorrectLyric = true; - System.Collections.ArrayList strLyric = new System.Collections.ArrayList(); StringBuilder lyricTemp = new StringBuilder(); WebClient client = (WebClient)sender; Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/HotLyrics.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/HotLyrics.cs 2007-04-16 22:06:02 UTC (rev 335) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/HotLyrics.cs 2007-04-16 22:15:24 UTC (rev 336) @@ -10,7 +10,7 @@ class HotLyrics { string lyric = ""; - bool complete = false; + bool complete; public string Lyric { @@ -19,11 +19,11 @@ public HotLyrics(string artist, string title) { - if (LyricDiagnostics.TraceSource != null) LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Information, 0, LyricDiagnostics.elapsedTimeString() + "SeekLyrics(" + artist + ", " + title + ")"); + if (LyricDiagnostics.TraceSource != null) LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Information, 0, LyricDiagnostics.ElapsedTimeString() + "SeekLyrics(" + artist + ", " + title + ")"); - artist = LyricUtil.removeFeatComment(artist); - LyricUtil.trimForParenthesis(ref artist); - artist = LyricUtil.capatalizeString(artist); + artist = LyricUtil.RemoveFeatComment(artist); + artist = LyricUtil.TrimForParenthesis(artist); + artist = LyricUtil.CapatalizeString(artist); artist = artist.Replace(" ", "_"); artist = artist.Replace(",", "_"); @@ -50,9 +50,9 @@ // French letters artist = artist.Replace("\xE9", "%E9"); - title = LyricUtil.removeFeatComment(title); - LyricUtil.trimForParenthesis(ref title); - title = LyricUtil.capatalizeString(title); + title = LyricUtil.RemoveFeatComment(title); + title = LyricUtil.TrimForParenthesis(title); + title = LyricUtil.CapatalizeString(title); title = title.Replace(" ", "_"); title = title.Replace(",", "_"); @@ -108,7 +108,6 @@ private void callbackMethod(object sender, OpenReadCompletedEventArgs e) { bool thisMayBeTheCorrectLyric = true; - System.Collections.ArrayList strLyric = new System.Collections.ArrayList(); StringBuilder lyricTemp = new StringBuilder(); WebClient client = (WebClient)sender; Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/Lyrics007.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/Lyrics007.cs 2007-04-16 22:06:02 UTC (rev 335) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/Lyrics007.cs 2007-04-16 22:15:24 UTC (rev 336) @@ -10,7 +10,7 @@ class Lyrics007 { string lyric = ""; - bool complete = false; + bool complete; public string Lyric { @@ -19,13 +19,13 @@ public Lyrics007(string artist, string title) { - if (LyricDiagnostics.TraceSource != null) LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Information, 0, LyricDiagnostics.elapsedTimeString() + "Lyrics007(" + artist + ", " + title + ")"); + if (LyricDiagnostics.TraceSource != null) LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Information, 0, LyricDiagnostics.ElapsedTimeString() + "Lyrics007(" + artist + ", " + title + ")"); - artist = LyricUtil.removeFeatComment(artist); - LyricUtil.trimForParenthesis(ref artist); + artist = LyricUtil.RemoveFeatComment(artist); + artist = LyricUtil.TrimForParenthesis(artist); artist = artist.Replace("#", ""); - title = LyricUtil.removeFeatComment(title); - LyricUtil.trimForParenthesis(ref title); + title = LyricUtil.RemoveFeatComment(title); + title = LyricUtil.TrimForParenthesis(title); title = title.Replace("#", ""); // Cannot find lyrics contaning non-English letters! @@ -48,7 +48,6 @@ private void callbackMethod(object sender, OpenReadCompletedEventArgs e) { bool thisMayBeTheCorrectLyric = true; - System.Collections.ArrayList strLyric = new System.Collections.ArrayList(); StringBuilder lyricTemp = new StringBuilder(); WebClient client = (WebClient)sender; Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/LyricsOnDemand.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/LyricsOnDemand.cs 2007-04-16 22:06:02 UTC (rev 335) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/LyricsOnDemand.cs 2007-04-16 22:15:24 UTC (rev 336) @@ -10,7 +10,7 @@ class LyricsOnDemand { string lyric = ""; - bool complete = false; + bool complete; public string Lyric { @@ -19,11 +19,11 @@ public LyricsOnDemand(string artist, string title) { - if (LyricDiagnostics.TraceSource != null) LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Information, 0, LyricDiagnostics.elapsedTimeString() + "LyricsOnDemand(" + artist + ", " + title + ")"); + if (LyricDiagnostics.TraceSource != null) LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Information, 0, LyricDiagnostics.ElapsedTimeString() + "LyricsOnDemand(" + artist + ", " + title + ")"); - artist = LyricUtil.removeFeatComment(artist); - LyricUtil.trimForParenthesis(ref artist); - LyricUtil.deleteSpecificChars(ref artist); + artist = LyricUtil.RemoveFeatComment(artist); + artist = LyricUtil.TrimForParenthesis(artist); + artist = LyricUtil.DeleteSpecificChars(artist); artist = artist.Replace(" ", ""); artist = artist.Replace("The ", ""); artist = artist.Replace("the ", ""); @@ -33,9 +33,9 @@ // Cannot find lyrics contaning non-English letters! - title = LyricUtil.removeFeatComment(title); - LyricUtil.trimForParenthesis(ref title); - LyricUtil.deleteSpecificChars(ref title); + title = LyricUtil.RemoveFeatComment(title); + title = LyricUtil.TrimForParenthesis(title); + title = LyricUtil.DeleteSpecificChars(title); title = title.Replace(" ", ""); title = title.Replace("#", ""); artist = artist.Replace("-", ""); @@ -54,12 +54,11 @@ if (artist.Length > 0) firstLetter = artist[0].ToString(); - try + int firstNumber = 0; + if (int.TryParse(firstLetter, out firstNumber)) { - int.Parse(firstLetter); firstLetter = "0"; } - catch { ;}; string urlString = "http://www.lyricsondemand.com/" + firstLetter + "/" + artist + "lyrics/" + title + "lyrics.html"; @@ -78,7 +77,6 @@ private void callbackMethod(object sender, OpenReadCompletedEventArgs e) { bool thisMayBeTheCorrectLyric = true; - System.Collections.ArrayList strLyric = new System.Collections.ArrayList(); StringBuilder lyricTemp = new StringBuilder(); WebClient client = (WebClient)sender; Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/SeekLyrics.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/SeekLyrics.cs 2007-04-16 22:06:02 UTC (rev 335) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/SeekLyrics.cs 2007-04-16 22:15:24 UTC (rev 336) @@ -10,7 +10,7 @@ class SeekLyrics { string lyric = ""; - bool complete = false; + bool complete; public string Lyric { @@ -19,10 +19,10 @@ public SeekLyrics(string artist, string title) { - if (LyricDiagnostics.TraceSource != null) LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Information, 0, LyricDiagnostics.elapsedTimeString() + "SeekLyrics(" + artist + ", " + title + ")"); + if (LyricDiagnostics.TraceSource != null) LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Information, 0, LyricDiagnostics.ElapsedTimeString() + "SeekLyrics(" + artist + ", " + title + ")"); - artist = LyricUtil.removeFeatComment(artist); - LyricUtil.trimForParenthesis(ref artist); + artist = LyricUtil.RemoveFeatComment(artist); + artist = LyricUtil.TrimForParenthesis(artist); artist = artist.Replace(" ", "-"); artist = artist.Replace("'", "-"); artist = artist.Replace("(", ""); @@ -42,8 +42,8 @@ // French letters artist = artist.Replace("\xE9", "%E9"); - title = LyricUtil.removeFeatComment(title); - LyricUtil.trimForParenthesis(ref title); + title = LyricUtil.RemoveFeatComment(title); + title = LyricUtil.TrimForParenthesis(title); title = title.Replace(" ", "-"); title = title.Replace("'", "-"); title = title.Replace("(", ""); @@ -82,7 +82,6 @@ private void callbackMethod(object sender, OpenReadCompletedEventArgs e) { bool thisMayBeTheCorrectLyric = true; - System.Collections.ArrayList strLyric = new System.Collections.ArrayList(); StringBuilder lyricTemp = new StringBuilder(); WebClient client = (WebClient)sender; Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/Wiki.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/Wiki.cs 2007-04-16 22:06:02 UTC (rev 335) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/Wiki.cs 2007-04-16 22:15:24 UTC (rev 336) @@ -5,18 +5,17 @@ using LyricsEngine.org.lyricwiki; using LyricsEngine; -namespace MyLyricWiki +namespace LyricsEngine.LyricSites { public class Wiki { - private LyricWiki lyricWiki; - private LyricsResult lyricsResult = null; + private LyricsResult lyricsResult; private string artist = ""; private string title = ""; - private int noOfTries = 0; - public static bool Abort = false; - LyricSearch lyricSearch = null; + private int noOfTries; + public static bool Abort; + LyricSearch lyricSearch ; private string[] commonReplacementsLyricWiki = new string[16] { "<br>", "", "<BR>", "", "?d", "'d", "?s", "'s", "?t", "'t", "?v", "'v", "?e", "'e", "?r", "'r" }; private string[] commonRemoveFromLyricWiki = new string[2] { "[[category", "[[Category" }; @@ -29,7 +28,7 @@ delegate LyricsResult DelegateClass(string artist, string title); - private bool searchForWiki(string artist, string title) + private bool SearchForWiki() { DelegateClass del = lyricWiki.getSong; @@ -53,7 +52,7 @@ ++noOfTries; } - if (lyricsResult != null && isLyric(lyricsResult.lyrics)) + if (lyricsResult != null && IsLyric(lyricsResult.lyrics)) { return true; } @@ -62,64 +61,45 @@ noOfTries = 0; return false; } - } - public string getLyricAsynch(string artist, string title) + public string GetLyricAsynch(string artist, string title) { this.artist = artist; this.title = title; try { - // Step 1: search title as it is - //if (Abort == false && searchForWiki(this.artist, this.title)) - //{ - // return makeLyricFit(lyricsResult.lyrics); - //} - - // Step 2: search with parentheses and other disturbance removed - optimizeString(ref this.artist, ref this.title); - if (Abort == false && searchForWiki(this.artist, this.title)) + // search with parentheses and other disturbance removed + OptimizeString(ref this.artist, ref this.title); + if (Abort == false && SearchForWiki()) { - return (lyricsResult.lyrics); + return MakeLyricFit(lyricsResult.lyrics); } - // Step 3: search with altered and strings if any - //this.artist = LyricUtil.changeAnd_and_and(this.artist); - //this.title = LyricUtil.changeAnd_and_and(this.title); - //if (Abort == false && searchForWiki(this.artist, this.title)) - //{ - // return (lyricsResult.lyrics); - //} - - // final step: return "Not found" if no lyric found return "Not found"; } - catch (Exception e) + catch (Exception) { - //System.Windows.Forms.MessageBox.Show(e.ToString()); - //System.Windows.Forms.MessageBox.Show(lyricsResult.); - Console.Write(e.Message); return ""; } } - private bool isLyric(string lyric) + private bool IsLyric(string lyric) { - if (lyricsResult != null && !lyricsResult.lyrics.Equals("Not found") && !lyricsResult.lyrics.Equals("")) + if (lyricsResult != null && !lyricsResult.lyrics.Equals("Not found") && lyricsResult.lyrics.Length != 0) return true; else return false; } - private void optimizeString(ref string artist, ref string title) + private void OptimizeString(ref string artist, ref string title) { - LyricUtil.trimForParenthesis(ref artist); - LyricUtil.trimForParenthesis(ref title); + artist = LyricUtil.TrimForParenthesis(artist); + title = LyricUtil.TrimForParenthesis(title); } - private string makeLyricFit(string lyric) + private string MakeLyricFit(string lyric) { for (int i = 0; i < commonReplacementsLyricWiki.Length; i = i + 2) { @@ -135,7 +115,6 @@ break; } } - return lyric; } } Modified: trunk/plugins/MyLyrics/LyricsEngine/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/Properties/AssemblyInfo.cs 2007-04-16 22:06:02 UTC (rev 335) +++ trunk/plugins/MyLyrics/LyricsEngine/Properties/AssemblyInfo.cs 2007-04-16 22:15:24 UTC (rev 336) @@ -26,7 +26,7 @@ // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("0.19")] +[assembly: AssemblyVersion("0.20")] // // In order to sign your assembly you must specify a key to use. Refer to the Modified: trunk/plugins/MyLyrics/LyricsEngine/Setup.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/Setup.cs 2007-04-16 22:06:02 UTC (rev 335) +++ trunk/plugins/MyLyrics/LyricsEngine/Setup.cs 2007-04-16 22:15:24 UTC (rev 336) @@ -2,7 +2,7 @@ using System.Collections; using System.Text; -namespace LyricsEngineConfig +namespace LyricsEngine { public static class Setup { Modified: trunk/plugins/MyLyrics/My Lyrics/Convert/ConvertFromXMLtoLyricsDatabase.cs =================================================================== --- trunk/plugins/MyLyrics/My Lyrics/Convert/ConvertFromXMLtoLyricsDatabase.cs 2007-04-16 22:06:02 UTC (rev 335) +++ trunk/plugins/MyLyrics/My Lyrics/Convert/ConvertFromXMLtoLyricsDatabase.cs 2007-04-16 22:15:24 UTC (rev 336) @@ -4,6 +4,8 @@ using System.IO; using System.Xml; +using LyricsEngine.Database; + namespace MyLyrics { class ConvertFromXMLtoLyricsDatabase Modified: trunk/plugins/MyLyrics/My Lyrics/DatabaseUtil.cs =================================================================== --- trunk/plugins/MyLyrics/My Lyrics/DatabaseUtil.cs 2007-04-16 22:06:02 UTC (rev 335) +++ trunk/plugins/MyLyrics/My Lyrics/DatabaseUtil.cs 2007-04-16 22:15:24 UTC (rev 336) @@ -5,6 +5,7 @@ using System.Runtime.Serialization.Formatters.Binary; using LyricsEngine; +using LyricsEngine.Database; namespace MyLyrics { @@ -21,8 +22,8 @@ string lyricText = ""; try { - string capatalizedArtist = LyricUtil.capatalizeString(artist); - string capatalizedTitle = LyricUtil.capatalizeString(title); + string capatalizedArtist = LyricUtil.CapatalizeString(artist); + string capatalizedTitle = LyricUtil.CapatalizeString(title); lyricText = lyricDB[CorrectKeyFormat(capatalizedArtist, capatalizedTitle)].Lyrics; } @@ -46,7 +47,7 @@ string lyricsText = ""; try { - lyricsText = lyricMarkedDB[DatabaseUtil.CorrectKeyFormat(LyricUtil.capatalizeString(artist), LyricUtil.capatalizeString(title))].Lyrics; + lyricsText = lyricMarkedDB[DatabaseUtil.CorrectKeyFormat(LyricUtil.CapatalizeString(artist), LyricUtil.CapatalizeString(title))].Lyrics; } catch { @@ -61,7 +62,7 @@ string lyricText = ""; try { - lyricText = lyricDB[CorrectKeyFormat(LyricUtil.capatalizeString(artist), LyricUtil.capatalizeString(title))].Lyrics; + lyricText = lyricDB[CorrectKeyFormat(LyricUtil.CapatalizeString(artist), LyricUtil.CapatalizeString(title))].Lyrics; return lyricText.Replace("\n", "\r\n"); } catch Modified: trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs =================================================================== --- trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs 2007-04-16 22:06:02 UTC (rev 335) +++ trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs 2007-04-16 22:15:24 UTC (rev 336) @@ -11,7 +11,8 @@ using System.Timers; using LyricsEngine; -using LyricsEngineConfig; +using LyricsEngine.Database; +using LyricsEngine.LRC; using MediaPortal.GUI.Library; using MediaPortal.Dialogs; @@ -30,7 +31,7 @@ /// Summary description for Class1. /// </summary> - public class GUIMyLyrics : GUIWindow, ILyricForm, ISetupForm + public partial class GUIMyLyrics : GUIWindow, ILyricForm, ISetupForm { #region Fields related to the MyLyrics in general @@ -130,7 +131,7 @@ #region Fields related to LRC mode internal const int BASIC_WIDE_LIMIT = 45; - LRC.SimpleLRC lrc; + SimpleLRC lrc; IEnumerator enumerator; System.Windows.Forms.Timer timer; Stopwatch stopwatch; @@ -181,8 +182,8 @@ alreadyValidLRC = false; CurrentTrackTag = new MusicTag(); - CurrentTrackTag.Artist = LyricUtil.capatalizeString(GUIPropertyManager.GetProperty("#Play.Current.Artist")); - CurrentTrackTag.Title = LyricUtil.capatalizeString(GUIPropertyManager.GetProperty("#Play.Current.Title")); + CurrentTrackTag.Artist = LyricUtil.CapatalizeString(GUIPropertyManager.GetProperty("#Play.Current.Artist")); + CurrentTrackTag.Title = LyricUtil.CapatalizeString(GUIPropertyManager.GetProperty("#Play.Current.Title")); if (selectedScreen == (int)MyLyricsSettings.Screen.LRC_BASIC || selectedScreen == (int)MyLyricsSettings.Screen.LRC_WIDE) { @@ -194,7 +195,7 @@ m_title = CurrentTrackTag.Title; // Get lyric - if (!CurrentTrackTag.Artist.Equals("")) + if (CurrentTrackTag.Artist.Length != 0) { findLyric(); } @@ -216,8 +217,8 @@ { newTrack = false; - m_artist = LyricUtil.capatalizeString(GUIPropertyManager.GetProperty("#Play.Current.Artist")); - m_title = LyricUtil.capatalizeString(GUIPropertyManager.GetProperty("#Play.Current.Title")); + m_artist = LyricUtil.CapatalizeString(GUIPropertyManager.GetProperty("#Play.Current.Artist")); + m_title = LyricUtil.CapatalizeString(GUIPropertyManager.GetProperty("#Play.Current.Title")); if (DatabaseUtil.IsTrackInLyricsDatabase(LyricsDB, m_artist, m_title).Equals(DatabaseUtil.LYRIC_FOUND)) { @@ -239,53 +240,14 @@ base.Process(); } - public void getAlbumArt() - { - ImagePathContainer.Clear(); - CurrentTrackFileName = g_Player.CurrentFile; - GetTrackTags(); - CurrentThumbFileName = GUIMusicFiles.GetCoverArt(false, CurrentTrackFileName, CurrentTrackTag); - if (CurrentThumbFileName.Length > 0) - { - // let us test if there is a larger cover art image - string strLarge = MediaPortal.Util.Utils.ConvertToLargeCoverArt(CurrentThumbFileName); - if (System.IO.File.Exists(strLarge)) - CurrentThumbFileName = strLarge; - AddImageToImagePathContainer(CurrentThumbFileName); - } - - CurrentThumbFileName = GUIMusicFiles.GetArtistCoverArtName(CurrentTrackTag.Artist); - if (CurrentThumbFileName.Length > 0) - { - // let us test if there is a larger cover art image - string strLarge = MediaPortal.Util.Utils.ConvertToLargeCoverArt(CurrentThumbFileName); - if (System.IO.File.Exists(strLarge)) - CurrentThumbFileName = strLarge; - AddImageToImagePathContainer(CurrentThumbFileName); - } - - UpdateImagePathContainer(); - } - - private void UpdateTrackPosition() - { - double trackDuration = g_Player.Duration; - double curTrackPostion = g_Player.CurrentPosition; - - int progPrecent = (int)(curTrackPostion / trackDuration * 100d); - - this.GUIelement_ProgTrack.Percentage = progPrecent; - GUIelement_ProgTrack.Visible = GUIelement_ProgTrack.Percentage > 0; - } - private void startSearch() { lyricsFound = false; StopThread(); newTrack = false; - if (!CurrentTrackTag.Artist.Equals("")) findLyric(); + if (CurrentTrackTag.Artist.Length != 0) findLyric(); else { m_artist = ""; @@ -301,7 +263,7 @@ private void showLRCtoEdit() { - LRC.SimpleLRC lrc = new LRC.SimpleLRC(m_artist, m_title, m_LyricText); + SimpleLRC lrc = new SimpleLRC(m_artist, m_title, m_LyricText); if (lrc.IsValid) { @@ -401,14 +363,14 @@ LoadSettings(); LyricDiagnostics.OpenLog(MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Log, logName)); - LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Start, 0, LyricDiagnostics.elapsedTimeString() + "MyLyrics opens."); + LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Start, 0, LyricDiagnostics.ElapsedTimeString() + "MyLyrics opens."); return true; } case GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT: { StopThread(); resetAll(); - LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Stop, 0, LyricDiagnostics.elapsedTimeString() + "MyLyrics closes."); + LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Stop, 0, LyricDiagnostics.ElapsedTimeString() + "MyLyrics closes."); break; } } @@ -435,46 +397,7 @@ //} } - private void OnImageTimerTickEvent(object trash_, ElapsedEventArgs args_) - { - FlipPictures(); - } - private void FlipPictures() - { - //// Check if we should let the visualization window handle image flipping - //if (_usingBassEngine && _showVisualization) - // return; - - if (GUIelement_ImgCoverArt != null) - { - GUIelement_ImgCoverArt.FreeResources(); - if (ImagePathContainer.Count > 0) - { - if (ImagePathContainer.Count > 1) - { - int currentImage = 0; - // get the next image - foreach (string image in ImagePathContainer) - { - currentImage++; - if (GUIelement_ImgCoverArt.FileName == image) - break; - } - if (currentImage < ImagePathContainer.Count) - GUIelement_ImgCoverArt.SetFileName(ImagePathContainer[currentImage]); - else - // start loop again - GUIelement_ImgCoverArt.SetFileName(ImagePathContainer[0]); - } - else - GUIelement_ImgCoverArt.SetFileName(ImagePathContainer[0]); - } - GUIelement_ImgCoverArt.AllocResources(); - } - } - - public override void OnAction(Action action) { switch (action.wID) @@ -543,7 +466,7 @@ { if (tag2.Equals("#Play.Current.Track") && !exitingMyLyrics) // track has changed { - if (!value.Equals("")) // additional check + if (value.Length != 0) // additional check { basicScreenSelected = null; resetGUI(selectedScreen); @@ -570,229 +493,7 @@ } } - private void GetTrackTags() - { - bool isCurSongCdTrack = IsCdTrack(CurrentTrackFileName); - bool isNextSongCdTrack = IsCdTrack(NextTrackFileName); - MusicDatabase dbs = new MusicDatabase(); - if (CurrentTrackTag != null) - PreviousTrackTag = CurrentTrackTag; - - if (!isCurSongCdTrack) - CurrentTrackTag = GetTrackTag(dbs, CurrentTrackFileName, UseID3); - - if (!isNextSongCdTrack) - NextTrackTag = GetTrackTag(dbs, NextTrackFileName, UseID3); - - if (isCurSongCdTrack || isNextSongCdTrack) - { - PlayList curPlaylist = PlaylistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC); - - int iCurItemIndex = PlaylistPlayer.CurrentSong; - PlayListItem curPlaylistItem = curPlaylist[iCurItemIndex]; - - if (curPlaylistItem == null) - { - CurrentTrackTag = null; - NextTrackTag = null; - return; - } - - int playListItemCount = curPlaylist.Count; - int nextItemIndex = 0; - - if (iCurItemIndex < playListItemCount - 1) - nextItemIndex = iCurItemIndex + 1; - - PlayListItem nextPlaylistItem = curPlaylist[nextItemIndex]; - - if (isCurSongCdTrack) - CurrentTrackTag = (MusicTag)curPlaylistItem.MusicTag; - - if (isNextSongCdTrack && nextPlaylistItem != null) - NextTrackTag = (MusicTag)nextPlaylistItem.MusicTag; - - // There's no MusicTag info in the Playlist so check is we have a valid - // GUIMusicFiles.MusicCD object - if ((CurrentTrackTag == null || NextTrackTag == null) && GUIMusicFiles.MusicCD != null) - { - int curCDTrackNum = GetCDATrackNumber(CurrentTrackFileName); - int nextCDTrackNum = GetCDATrackNumber(NextTrackFileName); - - if (curCDTrackNum < GUIMusicFiles.MusicCD.Tracks.Length) - { - MediaPortal.Freedb.CDTrackDetail curTrack = GUIMusicFiles.MusicCD.getTrack(curCDTrackNum); - CurrentTrackTag = GetTrackTag(curTrack); - } - if (nextCDTrackNum < GUIMusicFiles.MusicCD.Tracks.Length) - { - MediaPortal.Freedb.CDTrackDetail nextTrack = GUIMusicFiles.MusicCD.getTrack(nextCDTrackNum); - NextTrackTag = GetTrackTag(nextTrack); - } - } - } - } - - private bool IsCdTrack(string fileName) - { - return System.IO.Path.GetExtension(CurrentTrackFileName).ToLower() == ".cda"; - } - - int GetCDATrackNumber(string strFile) - { - string strTrack = string.Empty; - int pos = strFile.IndexOf(".cda"); - if (pos >= 0) - { - pos--; - while (Char.IsDigit(strFile[pos]) && pos > 0) - { - strTrack = strFile[pos] + strTrack; - pos--; - } - } - - try - { - int iTrack = Convert.ToInt32(strTrack); - return iTrack; - } - catch (Exception) - { - } - - return 1; - } - - private MusicTag GetTrackTag(MediaPortal.Freedb.CDTrackDetail cdTrack) - { - if (GUIMusicFiles.MusicCD == null) - return null; - MusicTag tag = new MusicTag(); - tag.Artist = GUIMusicFiles.MusicCD.Artist; - tag.Album = GUIMusicFiles.MusicCD.Title; - tag.Genre = GUIMusicFiles.MusicCD.Genre; - tag.Year = GUIMusicFiles.MusicCD.Year; - tag.Duration = cdTrack.Duration; - tag.Title = cdTrack.Title; - return tag; - } - - private MusicTag GetTrackTag(MusicDatabase dbs, string strFile, bool useID3) - { - MusicTag tag = null; - Song song = new Song(); - bool bFound = dbs.GetSongByFileName(strFile, ref song); - if (!bFound) - { - if (useID3) - tag = TagReader.ReadTag(strFile); - } - else - { - tag = new MusicTag(); - tag = BuildMusicTagFromSong(song); - } - return tag; - } - - private MusicTag BuildMusicTagFromSong(Song Song_) - { - MusicTag tmpTag = new MusicTag(); - - tmpTag.Title = Song_.Title; - tmpTag.Album = Song_.Album; - tmpTag.Artist = Song_.Artist; - tmpTag.Duration = Song_.Duration; - tmpTag.Genre = Song_.Genre; - tmpTag.Track = Song_.Track; - tmpTag.Year = Song_.Year; - tmpTag.Rating = Song_.Rating; - - return tmpTag; - } - - - private void UpdateImagePathContainer() - { - if (ImagePathContainer.Count <= 0) - { - try - { - GUIelement_ImgCoverArt.SetFileName(GUIGraphicsContext.Skin + @"\media\missing_coverart.png"); - } - catch (Exception ex) - { - Log.Debug("GUIMusicPlayingNow: could not set default image - {0}", ex.Message); - } - } - - if (g_Player.Duration > 0 && ImagePathContainer.Count > 1) - // ImageChangeTimer.Interval = (g_Player.Duration * 1000) / (ImagePathContainer.Count * 8); // change each cover 8x - ImageChangeTimer.Interval = 15 * 1000; // change covers every 15 seconds - else - ImageChangeTimer.Interval = 3600 * 1000; - - ImageChangeTimer.Stop(); - ImageChangeTimer.Start(); - } - - private bool AddImageToImagePathContainer(string newImage) - { - lock (_imageMutex) - { - string ImagePath = Convert.ToString(newImage); - if (ImagePath.IndexOf(@"missing_coverart") > 0)// && (ImagePathContainer.Count > 0)) - { - Log.Debug("GUIMusicPlayingNow: Found placeholder - not inserting image {0}", ImagePath); - return false; - } - - bool success = false; - if (ImagePathContainer != null) - { - if (ImagePathContainer.Contains(ImagePath)) - return false; - - //// check for placeholder - //int indexDel = 0; - //bool found = false; - //foreach (string pic in ImagePathContainer) - //{ - // indexDel++; - // if (pic.IndexOf("missing_coverart.png") > 0) - // { - // found = true; - // break; - // } - //} - //if (found) - // ImagePathContainer.RemoveAt(indexDel - 1); - - if (System.IO.File.Exists(ImagePath)) - { - try - { - Log.Debug("GUIMusicPlayingNow: adding image to container - {0}", ImagePath); - ImagePathContainer.Add(ImagePath); - success = true; - } - catch (Exception ex) - { - Log.Error("GUIMusicPlayingNow: error adding image ({0}) - {1}", ImagePath, ex.Message); - } - - // display the first pic automatically - if (ImagePathContainer.Count == 1) - FlipPictures(); - } - } - - return success; - } - } - //event driven handler to detect track change private void timeHandler(string tag2, string value) { @@ -834,7 +535,7 @@ m_StatusText = "Searching for a matching lyric..."; GUIControl.SetControlLabel(GetID, (int)GUI_General_Controls.CONTROL_LBStatus, m_StatusText); - LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Information, 0, LyricDiagnostics.elapsedTimeString() + "findLyric(" + m_artist + ", " + m_title + ")"); + LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Information, 0, LyricDiagnostics.ElapsedTimeString() + "findLyric(" + m_artist + ", " + m_title + ")"); /* The search order for a lyric of the currently played file is as follows: 1) LRC in music tag @@ -847,8 +548,8 @@ // 1) + 2) Check if LRC in music tag or Database string lyricText = MyLyrics.DatabaseUtil.LookUpLyricInDatabase(LyricsDB, m_artist, m_title); - if ((!CurrentTrackTag.Lyrics.Equals("") && (lrc = new LRC.SimpleLRC(m_artist, m_title, CurrentTrackTag.Lyrics)).IsValid) - || (!lyricText.Equals("") && (lrc = new LRC.SimpleLRC(m_artist, m_title, lyricText)).IsValid)) + if ((CurrentTrackTag.Lyrics.Length != 0 && (lrc = new SimpleLRC(m_artist, m_title, CurrentTrackTag.Lyrics)).IsValid) + || (lyricText.Length != 0 && (lrc = new SimpleLRC(m_artist, m_title, lyricText)).IsValid)) { resetLrcFields(); @@ -893,7 +594,7 @@ enumerator = lrc.SimpleLRCTimeAndLineCollection.GetEnumerator(); - if (!lrc.Artist.Equals("") && !lrc.Title.Equals("")) + if (lrc.Artist.Length != 0 && lrc.Title.Length != 0) { m_StatusText = ""; m_LyricText = ""; @@ -923,13 +624,13 @@ } // 2) Lyric in music tag - else if (!CurrentTrackTag.Lyrics.Equals("")) + else if (CurrentTrackTag.Lyrics.Length != 0) { ShowLyricOnScreen(CurrentTrackTag.Lyrics, CurrentTrackTag.FileName); } // 3) if lyric in music database - else if (!lyricText.Equals("")) + else if (lyricText.Length != 0) { LyricFound = new Object[] { lyricText, m_artist, m_title, "lyrics database" }; } @@ -950,7 +651,7 @@ m_LyricControllerThread.Name = "lyricSearch Thread"; // looks nice in Output window m_LyricControllerThread.Start(); - lc.addNewLyricSearch(m_artist, m_title); + lc.AddNewLyricSearch(m_artist, m_title); } } @@ -1020,8 +721,8 @@ } lyric.Replace("\r", ""); - string artist = LyricUtil.capatalizeString(m_artist); - string title = LyricUtil.capatalizeString(m_title); + string artist = LyricUtil.CapatalizeString(m_artist); + string title = LyricUtil.CapatalizeString(m_title); string lyricAsString = lyric.ToString(); int lastLineShift = lyricAsString.LastIndexOf("\n"); @@ -1085,14 +786,14 @@ { if (enumerator.MoveNext()) { - LRC.SimpleLRCTimeAndLine currentLine = (LRC.SimpleLRCTimeAndLine)enumerator.Current; + SimpleLRCTimeAndLine currentLine = (SimpleLRCTimeAndLine)enumerator.Current; while (currentLine.Time == 0) { m_LyricText += (currentLine.Line); ++currentLRCLine; enumerator.MoveNext(); - currentLine = (LRC.SimpleLRCTimeAndLine)enumerator.Current; + currentLine = (SimpleLRCTimeAndLine)enumerator.Current; } nextTimeToShow = currentLine.TimeString; @@ -1126,7 +827,7 @@ private void ShowLyricOnScreen(string lyricText, string source) { - LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Information, 0, LyricDiagnostics.elapsedTimeString() + "Lyric found: " + m_artist + " - " + m_title + ". Place: " + source); + LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Information, 0, LyricDiagnostics.ElapsedTimeString() + "Lyric found: " + m_artist + " - " + m_title + ". Place: " + source); lyricsFound = true; m_LyricText = lyricText; @@ -1157,8 +858,8 @@ private void SaveLyricToDatabase(string site) { - string capArtist = LyricUtil.capatalizeString(m_artist); - string capTitle = LyricUtil.capatalizeString(m_title); + string capArtist = LyricUtil.CapatalizeString(m_artist); + string capTitle = LyricUtil.CapatalizeString(m_title); if (DatabaseUtil.IsTrackInLyricsDatabase(LyricsDB, capArtist, capTitle).Equals(DatabaseUtil.LYRIC_NOT_FOUND)) { @@ -1506,7 +1207,7 @@ if (!lyricsFound && m_artist.Equals(artist) && m_title.Equals(title)) { - LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Information, 0, LyricDiagnostics.elapsedTimeString() + "Search terminates: No lyric found..."); + LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Information, 0, LyricDiagnostics.ElapsedTimeString() + "Search terminates: No lyric found..."); m_StatusText = "No lyric found"; GUIControl.SetControlLabel(GetID, (int)GUI_General_Controls.CONTROL_LBStatus, m_StatusText); } @@ -1518,7 +1219,7 @@ set ... [truncated message content] |