From: <Sil...@us...> - 2010-03-09 20:58:01
|
Revision: 3496 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=3496&view=rev Author: SilentException Date: 2010-03-09 20:57:54 +0000 (Tue, 09 Mar 2010) Log Message: ----------- * some refactoring * inserted few functions from mediaportal guiplayingnow to try to improve artist/track detection and publishing of play properties * setting for new option always ask for upload to lrcfinder was never saved Modified Paths: -------------- trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/MyLyricsSetup.cs trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs trunk/plugins/MyLyrics/My Lyrics/MyLyricsExternCode.cs Modified: trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/MyLyricsSetup.cs =================================================================== --- trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/MyLyricsSetup.cs 2010-03-08 18:30:36 UTC (rev 3495) +++ trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/MyLyricsSetup.cs 2010-03-09 20:57:54 UTC (rev 3496) @@ -1244,6 +1244,7 @@ xmlwriter.SetValue("myLyrics", "useLyricsPluginSite", cbLyricsPluginSite.Checked.ToString()); xmlwriter.SetValueAsBool("myLyrics", "useAutoscroll", cbUseAutoScrollAsDefault.Checked); xmlwriter.SetValueAsBool("myLyrics", "uploadLrcToLrcFinder", cbUploadLrcAutomatically.Checked); + xmlwriter.SetValueAsBool("myLyrics", "alwaysAskUploadLrcToLrcFinder", cbAlwaysAskForUploadToLrcFinder.Checked); xmlwriter.SetValue("myLyrics", "LrcTaggingName", tbLrcTaggingName.Text); xmlwriter.SetValueAsBool("myLyrics", "automaticFetch", cbAutoFetch.Checked); xmlwriter.SetValueAsBool("myLyrics", "automaticUpdateWhenFirstFound", cbAutomaticUpdate.Checked); Modified: trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs =================================================================== --- trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs 2010-03-08 18:30:36 UTC (rev 3495) +++ trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs 2010-03-09 20:57:54 UTC (rev 3496) @@ -40,7 +40,6 @@ private readonly object _imageMutex; private readonly List<String> _ImagePathContainer; - private readonly string _NextTrackFileName = string.Empty; private readonly PlayListPlayer _PlaylistPlayer; internal int CONTROL_LYRIC_SELECTED = 20; private string logFileName = "MyLyrics.log"; @@ -55,7 +54,10 @@ private int _crossfade; private string _CurrentThumbFileName = string.Empty; private string _CurrentTrackFileName = string.Empty; + private string _NextTrackFileName = string.Empty; private MusicTag _CurrentTrackTag; + private MusicTag _NextTrackTag; + private MusicTag _PreviousTrackTag; private bool _enableLogging; private string _Find = string.Empty; @@ -78,8 +80,6 @@ private List<string[]> _LyricsToWriteToTag; private string _LyricText = ""; private bool _newTrack; - private MusicTag _NextTrackTag; - private MusicTag _PreviousTrackTag; private string _Replace = string.Empty; private int _SearchingState; private int _selectedScreen; @@ -180,6 +180,42 @@ } + private void UpdateNextTrackInfo() + { + if (_NextTrackTag != null) + { + string strNextTrack = String.Format("{0} {1}", GUILocalizeStrings.Get(435), _NextTrackTag.Track); // "Track: " + if (_NextTrackTag.Track <= 0) + { + strNextTrack = string.Empty; + } + + string strYear = String.Format("{0} {1}", GUILocalizeStrings.Get(436), _NextTrackTag.Year); // "Year: " + if (_NextTrackTag.Year <= 1900) + { + strYear = string.Empty; + } + + GUIPropertyManager.SetProperty("#Play.Next.Title", _NextTrackTag.Title); + GUIPropertyManager.SetProperty("#Play.Next.Track", strNextTrack); + GUIPropertyManager.SetProperty("#Play.Next.Album", _NextTrackTag.Album); + GUIPropertyManager.SetProperty("#Play.Next.Artist", _NextTrackTag.Artist); + GUIPropertyManager.SetProperty("#Play.Next.Genre", _NextTrackTag.Genre); + GUIPropertyManager.SetProperty("#Play.Next.Year", strYear); + GUIPropertyManager.SetProperty("#Play.Next.Rating", (Convert.ToDecimal(2 * _NextTrackTag.Rating + 1)).ToString()); + } + else + { + GUIPropertyManager.SetProperty("#Play.Next.Title", string.Empty); + GUIPropertyManager.SetProperty("#Play.Next.Track", string.Empty); + GUIPropertyManager.SetProperty("#Play.Next.Album", string.Empty); + GUIPropertyManager.SetProperty("#Play.Next.Artist", string.Empty); + GUIPropertyManager.SetProperty("#Play.Next.Genre", string.Empty); + GUIPropertyManager.SetProperty("#Play.Next.Year", string.Empty); + GUIPropertyManager.SetProperty("#Play.Next.Rating", "0"); + } + } + public override void Process() { if ((_newTrack || _SearchingState != (int)SEARCH_STATE.NOT_SEARCHING) @@ -209,8 +245,12 @@ currentFile = _CurrentTrackTag.FileName; currentLyrics = _CurrentTrackTag.Lyrics; } - _CurrentTrackTag = mDB.GetTag(g_Player.CurrentFile); + _CurrentTrackFileName = g_Player.CurrentFile; + _NextTrackFileName = PlayListPlayer.SingletonPlayer.GetNext(); + //_CurrentTrackTag = mDB.GetTag(g_Player.CurrentFile); + GetTrackTags(); + if (_CurrentTrackTag != null) { _artist = _CurrentTrackTag.Artist.Trim(); @@ -259,11 +299,32 @@ { if (!g_Player.IsRadio) { - _CurrentTrackTag.Artist = - LyricUtil.CapatalizeString(GUIPropertyManager.GetProperty("#Play.Current.Artist")); - _CurrentTrackTag.Title = - LyricUtil.CapatalizeString(GUIPropertyManager.GetProperty("#Play.Current.Title")); + string strTrack = String.Format("{0} {1}", GUILocalizeStrings.Get(435), _CurrentTrackTag.Track); // "Track" + if (_CurrentTrackTag.Track <= 0) + { + strTrack = string.Empty; + } + + string strYear = String.Format("{0} {1}", GUILocalizeStrings.Get(436), _CurrentTrackTag.Year); // "Year: " + if (_CurrentTrackTag.Year <= 1900) + { + strYear = string.Empty; + } + + GUIPropertyManager.SetProperty("#Play.Current.Title", _CurrentTrackTag.Title); + GUIPropertyManager.SetProperty("#Play.Current.Track", strTrack); + GUIPropertyManager.SetProperty("#Play.Current.Album", _CurrentTrackTag.Album); + GUIPropertyManager.SetProperty("#Play.Current.Artist", _CurrentTrackTag.Artist); + GUIPropertyManager.SetProperty("#Play.Current.Genre", _CurrentTrackTag.Genre); + GUIPropertyManager.SetProperty("#Play.Current.Year", strYear); + GUIPropertyManager.SetProperty("#Play.Current.Rating", (Convert.ToDecimal(2 * _CurrentTrackTag.Rating + 1)).ToString()); + GUIPropertyManager.SetProperty("#duration", MediaPortal.Util.Utils.SecondsToHMSString(_CurrentTrackTag.Duration)); + + //_CurrentTrackTag.Artist = LyricUtil.CapatalizeString(GUIPropertyManager.GetProperty("#Play.Current.Artist")); + //_CurrentTrackTag.Title = LyricUtil.CapatalizeString(GUIPropertyManager.GetProperty("#Play.Current.Title")); _CurrentTrackTag.Lyrics = LyricUtil.FixLyrics(_CurrentTrackTag.Lyrics); + + UpdateNextTrackInfo(); } if (_selectedScreen == (int)MyLyricsSettings.Screen.LYRICS @@ -530,20 +591,17 @@ private bool useEditControlsOnLRCPick() { - string blacklistedControlIDs = String.Empty; + string useEditControlsOnLRCPick = String.Empty; if (defines != null && defines.Contains("#MyLyrics.UseEditControlsOnLRCPick")) - blacklistedControlIDs = (string)defines["#MyLyrics.UseEditControlsOnLRCPick"]; - foreach (string cID in blacklistedControlIDs.Split(new char[] { ',' })) + useEditControlsOnLRCPick = (string)defines["#MyLyrics.UseEditControlsOnLRCPick"]; + try { - try - { - if (cID.ToUpper() == "TRUE" || cID.ToUpper() == "YES") - return true; - } - catch - { - } + if (useEditControlsOnLRCPick.ToUpper() == "TRUE" || useEditControlsOnLRCPick.ToUpper() == "YES") + return true; } + catch + { + } return false; } Modified: trunk/plugins/MyLyrics/My Lyrics/MyLyricsExternCode.cs =================================================================== --- trunk/plugins/MyLyrics/My Lyrics/MyLyricsExternCode.cs 2010-03-08 18:30:36 UTC (rev 3495) +++ trunk/plugins/MyLyrics/My Lyrics/MyLyricsExternCode.cs 2010-03-09 20:57:54 UTC (rev 3496) @@ -19,6 +19,7 @@ public void GetAlbumArt() { _CurrentTrackFileName = g_Player.CurrentFile; + _NextTrackFileName = PlayListPlayer.SingletonPlayer.GetNext(); GetTrackTags(); _CurrentThumbFileName = GUIMusicFiles.GetCoverArt(false, _CurrentTrackFileName, _CurrentTrackTag); @@ -100,22 +101,25 @@ { bool isCurSongCdTrack = IsCdTrack(_CurrentTrackFileName); bool isNextSongCdTrack = IsCdTrack(_NextTrackFileName); + bool isInternetStream = Utils.IsAVStream(_CurrentTrackFileName); MusicDatabase dbs = MusicDatabase.Instance; if (_CurrentTrackTag != null) _PreviousTrackTag = _CurrentTrackTag; - if (!isCurSongCdTrack) + if (!isCurSongCdTrack && !isInternetStream) { - _CurrentTrackTag = dbs.GetTag(_CurrentTrackFileName); - _CurrentTrackTag.Artist = - LyricUtil.CapatalizeString(GUIPropertyManager.GetProperty("#Play.Current.Artist")); - _CurrentTrackTag.Title = - LyricUtil.CapatalizeString(GUIPropertyManager.GetProperty("#Play.Current.Title")); + _CurrentTrackTag = GetTrackTag(dbs, _CurrentTrackFileName, true); + //_CurrentTrackTag = dbs.GetTag(_CurrentTrackFileName); + //_CurrentTrackTag.Artist = LyricUtil.CapatalizeString(GUIPropertyManager.GetProperty("#Play.Current.Artist")); + //_CurrentTrackTag.Title = LyricUtil.CapatalizeString(GUIPropertyManager.GetProperty("#Play.Current.Title")); } - if (!isNextSongCdTrack) - _NextTrackTag = dbs.GetTag(_NextTrackFileName); + if (!isNextSongCdTrack && !isInternetStream) + { + _NextTrackTag = GetTrackTag(dbs, _NextTrackFileName, true); + //_NextTrackTag = dbs.GetTag(_NextTrackFileName); + } if (isCurSongCdTrack || isNextSongCdTrack) { @@ -140,10 +144,10 @@ PlayListItem nextPlaylistItem = curPlaylist[nextItemIndex]; if (isCurSongCdTrack) - _CurrentTrackTag = (MusicTag) curPlaylistItem.MusicTag; + _CurrentTrackTag = (MusicTag)curPlaylistItem.MusicTag; if (isNextSongCdTrack && nextPlaylistItem != null) - _NextTrackTag = (MusicTag) nextPlaylistItem.MusicTag; + _NextTrackTag = (MusicTag)nextPlaylistItem.MusicTag; // There's no MusicTag info in the Playlist so check is we have a valid // GUIMusicFiles.MusicCD object @@ -156,10 +160,8 @@ { CDTrackDetail curTrack = GUIMusicFiles.MusicCD.getTrack(curCDTrackNum); _CurrentTrackTag = GetTrackTag(curTrack); - _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 (nextCDTrackNum < GUIMusicFiles.MusicCD.Tracks.Length) { @@ -168,6 +170,14 @@ } } } + + // If we got an Internetstream and are playing via BASS Player + // then receive the MusicTags from the stream + if (isInternetStream && BassMusicPlayer.IsDefaultMusicPlayer) + { + _NextTrackTag = null; + _CurrentTrackTag = BassMusicPlayer.Player.GetStreamTags(); + } } private bool IsCdTrack(string fileName) @@ -223,13 +233,20 @@ if (!bFound) { if (useID3) + { tag = TagReader.ReadTag(strFile); + if (tag != null && tag.Title != GUILocalizeStrings.Get(4543)) // Track information not available + { + return tag; + } + } + // tagreader failed or not using it + song.Title = Path.GetFileNameWithoutExtension(strFile); + song.Artist = string.Empty; + song.Album = string.Empty; } - else - { - tag = new MusicTag(); - tag = BuildMusicTagFromSong(song); - } + tag = new MusicTag(); + tag = song.ToMusicTag(); return tag; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |