Пример #1
0
        private void DoOnStarted(g_Player.MediaType type, string filename)
        {
            Log.Debug("GUIMusicPlayingNow: g_Player_PlayBackStarted for {0}", filename);

            ImagePathContainer.Clear();
            CurrentTrackFileName = filename;
            GetTrackTags();

            CurrentThumbFileName = GUIMusicBaseWindow.GetCoverArt(false, CurrentTrackFileName, CurrentTrackTag);

            if (string.IsNullOrEmpty(CurrentThumbFileName))
            // no LOCAL Thumb found because user has bad settings -> check if there is a folder.jpg in the share
            {
                CurrentThumbFileName = Util.Utils.GetFolderThumb(CurrentTrackFileName);
                if (!Util.Utils.FileExistsInCache(CurrentThumbFileName))
                {
                    CurrentThumbFileName = string.Empty;
                }
            }

            if (!string.IsNullOrEmpty(CurrentThumbFileName))
            {
                // let us test if there is a larger cover art image
                string strLarge = Util.Utils.ConvertToLargeCoverArt(CurrentThumbFileName);
                if (Util.Utils.FileExistsInCache(strLarge))
                {
                    CurrentThumbFileName = strLarge;
                }
                AddImageToImagePathContainer(CurrentThumbFileName);
            }

            UpdateImagePathContainer();
            UpdateTrackInfo();
        }
Пример #2
0
        private void DoOnStarted(g_Player.MediaType type, string filename)
        {
            Log.Debug("GUIMusicPlayingNow: g_Player_PlayBackStarted for {0}", filename);

            ImagePathContainer.Clear();
            CurrentTrackFileName = filename;
            GetTrackTags();

            if (g_Player.IsRadio)
            {
                string strLogo = GUIPropertyManager.GetProperty("#Play.Current.Thumb");
                if (!string.IsNullOrEmpty(strLogo))
                {
                    CurrentThumbFileName = strLogo;
                }
                else
                {
                    CurrentThumbFileName = string.Empty;
                }
            }
            else
            {
                CurrentThumbFileName = GUIMusicBaseWindow.GetCoverArt(false, CurrentTrackFileName, CurrentTrackTag);
            }

            if (string.IsNullOrEmpty(CurrentThumbFileName))
            // no LOCAL Thumb found because user has bad settings -> check if there is a folder.jpg in the share
            {
                CurrentThumbFileName = Util.Utils.GetFolderThumb(CurrentTrackFileName);
                if (!Util.Utils.FileExistsInCache(CurrentThumbFileName))
                {
                    CurrentThumbFileName = string.Empty;
                }
            }

            if (!string.IsNullOrEmpty(CurrentThumbFileName))
            {
                // let us test if there is a larger cover art image
                string strLarge = Util.Utils.ConvertToLargeCoverArt(CurrentThumbFileName);
                if (Util.Utils.FileExistsInCache(strLarge))
                {
                    CurrentThumbFileName = strLarge;
                }
                AddImageToImagePathContainer(CurrentThumbFileName);
            }

            UpdateImagePathContainer();
            UpdateTrackInfo();

            // Do last.fm updates
            if (g_Player.IsMusic && _lookupSimilarTracks && g_Player.CurrentPosition >= 10.0 && lstSimilarTracks.Count == 0)
            {
                Log.Debug("GUIMusicPlayingNow: Do Last.FM lookup for similar tracks");
                UpdateSimilarTracks(CurrentTrackFileName);
            }
        }
Пример #3
0
        public void GetAlbumArt()
        {
            _currentTrackFileName = g_Player.CurrentFile;
            _nextTrackFileName    = PlayListPlayer.SingletonPlayer.GetNext();
            GetTrackTags();

            _currentThumbFileName = GUIMusicBaseWindow.GetCoverArt(false, _currentTrackFileName, _currentTrackTag);
            if (_currentThumbFileName.Length > 0)
            {
                // let us test if there is a larger cover art image
                var strLarge = Utils.ConvertToLargeCoverArt(_currentThumbFileName);
                if (File.Exists(strLarge))
                {
                    _currentThumbFileName = strLarge;
                }
                AddImageToImagePathContainer(_currentThumbFileName);
            }

            UpdateImagePathContainer();
        }
Пример #4
0
        /// <summary>
        /// Check for thumbs.   Will check for
        ///  1 - Local thumb (from users music collection)
        ///  2 - Already downloaded thumb from last.fm
        ///  3 - Last.fm thumb and download accordingly
        /// Thumbs are stored in temp folder and deleted when MP is closed
        /// </summary>
        /// <param name="item">Item to lookup thumb for</param>
        protected virtual void OnRetrieveCoverArt(GUIListItem item)
        {
            Util.Utils.SetDefaultIcons(item);
            if (item.Label == "..")
            {
                return;
            }
            var tag         = (MusicTag)item.MusicTag;
            var trackImgURL = tag.ImageURL;
            var tmpThumb    = GetTemporaryThumbName(trackImgURL);

            var strThumb = GUIMusicBaseWindow.GetCoverArt(item.IsFolder, item.Path, tag);

            if (strThumb != string.Empty)
            {
                UpdateListItemImage(item, strThumb);
            }
            else if (File.Exists(tmpThumb))
            {
                Log.Debug("last.fm thumb already exists for: {0} - {1}", tag.Artist, tag.Title);
                item.ThumbnailImage = tmpThumb;
                item.IconImageBig   = tmpThumb;
                item.IconImage      = tmpThumb;
                UpdateListItemImage(item, tmpThumb);
            }
            else
            {
                Log.Debug("Downloading last.fm thumb for: {0} - {1}", tag.Artist, tag.Title);
                if (!string.IsNullOrEmpty(trackImgURL))
                {
                    // download image from last.fm in background thread
                    var worker = new BackgroundWorker();
                    worker.DoWork += (obj, e) => ImageDownloadDoWork(trackImgURL, tmpThumb, item);
                    worker.RunWorkerAsync();
                }
            }
        }
Пример #5
0
        protected override void OnShowContextMenu()
        {
            GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
            MusicDatabase dbs;

            if (dlg == null)
            {
                return;
            }

            dlg.Reset();
            dlg.SetHeading(498);         // Menu

            dlg.AddLocalizedString(930); //Add to favorites

            if (CurrentTrackTag.Album != null)
            {
                dlg.AddLocalizedString(33041);
            }

            if (PluginManager.IsPluginNameEnabled2("LastFMScrobbler"))
            {
                dlg.AddLocalizedString(34010); //last.fm love
                dlg.AddLocalizedString(34011); //last.fm ban
            }

            dlg.DoModal(GetID);

            if (dlg.SelectedId == -1)
            {
                return;
            }

            switch (dlg.SelectedId)
            {
            case 928: // Find Coverart
                if (_MusicWindow != null)
                {
                    string albumFolderPath = Path.GetDirectoryName(CurrentTrackFileName);

                    _MusicWindow.FindCoverArt(false, CurrentTrackTag.Artist, CurrentTrackTag.Album, albumFolderPath,
                                              CurrentTrackTag, -1);
                    CurrentThumbFileName = GUIMusicBaseWindow.GetCoverArt(false, CurrentTrackFileName, CurrentTrackTag);

                    if (CurrentThumbFileName.Length > 0)
                    {
                        // let us test if there is a larger cover art image
                        string strLarge = Util.Utils.ConvertToLargeCoverArt(CurrentThumbFileName);
                        if (Util.Utils.FileExistsInCache(strLarge))
                        {
                            CurrentThumbFileName = strLarge;
                        }
                        AddImageToImagePathContainer(CurrentThumbFileName);

                        UpdateImagePathContainer();
                    }
                }
                break;

            case 4521: // Show Album Info
                if (_MusicWindow != null)
                {
                    string albumFolderPath = Path.GetDirectoryName(CurrentTrackFileName);
                    if (_MusicWindow != null)
                    {
                        _MusicWindow.ShowAlbumInfo(GetID, CurrentTrackTag.Artist, CurrentTrackTag.Album);
                    }
                }
                break;

            case 930: // add to favorites
                dbs = MusicDatabase.Instance;
                Song   currentSong = new Song();
                string strFile     = g_Player.Player.CurrentFile;

                bool songFound = dbs.GetSongByFileName(strFile, ref currentSong);
                if (songFound)
                {
                    if (currentSong == null)
                    {
                        return;
                    }
                    if (currentSong.Id < 0)
                    {
                        return;
                    }
                    currentSong.Favorite = true;
                    dbs.SetFavorite(currentSong);
                }
                break;

            case 33041: //Play this album
                try
                {
                    if (CurrentTrackTag != null)
                    {
                        dbs = MusicDatabase.Instance;
                        ArrayList albumSongs = new ArrayList();
                        String    strAlbum   = CurrentTrackTag.Album;

                        bool albumSongsFound = dbs.GetSongsByAlbum(strAlbum, ref albumSongs);

                        if (albumSongsFound)
                        {
                            for (int i = albumSongs.Count - 1; i >= 0; i--)
                            {
                                Song song = (Song)albumSongs[i];
                                if (song.Title != CurrentTrackTag.Title && song.Artist == CurrentTrackTag.Artist)
                                {
                                    AddSongToPlaylist(ref song);
                                }
                            }
                            OnSongInserted();
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.Error("GUIMusicPlayingNow: error while adding album tracks for {0} - {1}", CurrentTrackTag.Album,
                              ex.Message);
                }
                break;
            }
        }
Пример #6
0
        private static void SetNextSkinProperties(MusicTag tag, String fileName)
        {
            var thumb = string.Empty;

            if (tag != null)
            {
                string strThumb = GUIMusicBaseWindow.GetCoverArt(false, fileName, tag);
                if (Util.Utils.FileExistsInCache(strThumb))
                {
                    thumb = strThumb;
                }

                // no succes with album cover try folder cache
                if (string.IsNullOrEmpty(thumb))
                {
                    thumb = Util.Utils.TryEverythingToGetFolderThumbByFilename(fileName, false);
                }

                // let us test if there is a larger cover art image
                string strLarge = Util.Utils.ConvertToLargeCoverArt(thumb);
                if (Util.Utils.FileExistsInCache(strLarge))
                {
                    thumb = strLarge;
                }

                if (!string.IsNullOrEmpty(thumb))
                {
                    GUIPropertyManager.SetProperty("#Play.Next.Thumb", thumb);
                }

                // Duration
                string strDuration = tag.Duration <= 0
                       ? string.Empty
                       : MediaPortal.Util.Utils.SecondsToHMSString(tag.Duration);

                // Track
                string strNextTrack = tag.Track <= 0 ? string.Empty : tag.Track.ToString();

                // Year
                string strYear = tag.Year <= 1900 ? string.Empty : tag.Year.ToString();

                // Rating
                string strRating = (Convert.ToDecimal(2 * tag.Rating + 1)).ToString();

                GUIPropertyManager.SetProperty("#Play.Next.Duration", strDuration);
                GUIPropertyManager.SetProperty("#Play.Next.Title", tag.Title);
                GUIPropertyManager.SetProperty("#Play.Next.Track", strNextTrack);
                GUIPropertyManager.SetProperty("#Play.Next.Album", tag.Album);
                GUIPropertyManager.SetProperty("#Play.Next.Artist", tag.Artist);
                GUIPropertyManager.SetProperty("#Play.Next.Genre", tag.Genre);
                GUIPropertyManager.SetProperty("#Play.Next.Year", strYear);
                GUIPropertyManager.SetProperty("#Play.Next.Rating", strRating);
                GUIPropertyManager.SetProperty("#Play.Next.AlbumArtist", tag.AlbumArtist);
                GUIPropertyManager.SetProperty("#Play.Next.BitRate", tag.BitRate.ToString());
                GUIPropertyManager.SetProperty("#Play.Next.Comment", tag.Comment);
                GUIPropertyManager.SetProperty("#Play.Next.Composer", tag.Composer);
                GUIPropertyManager.SetProperty("#Play.Next.Conductor", tag.Conductor);
                GUIPropertyManager.SetProperty("#Play.Next.DiscID", tag.DiscID.ToString());
                GUIPropertyManager.SetProperty("#Play.Next.DiscTotal", tag.DiscTotal.ToString());
                GUIPropertyManager.SetProperty("#Play.Next.Lyrics", tag.Lyrics);
                GUIPropertyManager.SetProperty("#Play.Next.TimesPlayed", tag.TimesPlayed.ToString());
                GUIPropertyManager.SetProperty("#Play.Next.TrackTotal", tag.TrackTotal.ToString());
                GUIPropertyManager.SetProperty("#Play.Next.FileType", tag.FileType);
                GUIPropertyManager.SetProperty("#Play.Next.Codec", tag.Codec);
                GUIPropertyManager.SetProperty("#Play.Next.BitRateMode", tag.BitRateMode);
                GUIPropertyManager.SetProperty("#Play.Next.BPM", tag.BPM.ToString());
                GUIPropertyManager.SetProperty("#Play.Next.Channels", tag.Channels.ToString());
                GUIPropertyManager.SetProperty("#Play.Next.SampleRate", tag.SampleRate.ToString());
                GUIPropertyManager.SetProperty("#Play.Next.DateLastPlayed", tag.DateTimePlayed.ToShortDateString());
                GUIPropertyManager.SetProperty("#Play.Next.DateAdded", tag.DateTimeModified.ToShortDateString());
            }
            else
            {
                GUIPropertyManager.SetProperty("#Play.Next.Thumb", string.Empty);
                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");
                GUIPropertyManager.SetProperty("#Play.Next.AlbumArtist", string.Empty);
                GUIPropertyManager.SetProperty("#Play.Next.BitRate", string.Empty);
                GUIPropertyManager.SetProperty("#Play.Next.Comment", string.Empty);
                GUIPropertyManager.SetProperty("#Play.Next.Composer", string.Empty);
                GUIPropertyManager.SetProperty("#Play.Next.Conductor", string.Empty);
                GUIPropertyManager.SetProperty("#Play.Next.DiscID", string.Empty);
                GUIPropertyManager.SetProperty("#Play.Next.DiscTotal", string.Empty);
                GUIPropertyManager.SetProperty("#Play.Next.Lyrics", string.Empty);
                GUIPropertyManager.SetProperty("#Play.Next.TimesPlayed", string.Empty);
                GUIPropertyManager.SetProperty("#Play.Next.TrackTotal", string.Empty);
                GUIPropertyManager.SetProperty("#Play.Next.FileType", string.Empty);
                GUIPropertyManager.SetProperty("#Play.Next.Codec", string.Empty);
                GUIPropertyManager.SetProperty("#Play.Next.BitRateMode", string.Empty);
                GUIPropertyManager.SetProperty("#Play.Next.BPM", string.Empty);
                GUIPropertyManager.SetProperty("#Play.Next.Channels", string.Empty);
                GUIPropertyManager.SetProperty("#Play.Next.SampleRate", string.Empty);
                GUIPropertyManager.SetProperty("#Play.Next.DateLastPlayed", string.Empty);
                GUIPropertyManager.SetProperty("#Play.Next.DateAdded", string.Empty);
            }
        }
Пример #7
0
        private static void SetCurrentSkinProperties(MusicTag tag, String fileName)
        {
            var thumb = string.Empty;

            if (tag != null)
            {
                string strThumb = GUIMusicBaseWindow.GetCoverArt(false, fileName, tag);
                if (Util.Utils.FileExistsInCache(strThumb))
                {
                    thumb = strThumb;
                }

                // no succes with album cover try folder cache
                if (string.IsNullOrEmpty(thumb))
                {
                    thumb = Util.Utils.TryEverythingToGetFolderThumbByFilename(fileName, false);
                }

                // let us test if there is a larger cover art image
                string strLarge = Util.Utils.ConvertToLargeCoverArt(thumb);
                if (Util.Utils.FileExistsInCache(strLarge))
                {
                    thumb = strLarge;
                }

                if (!Util.Utils.IsLastFMStream(fileName))
                {
                    GUIPropertyManager.SetProperty("#Play.Current.Thumb", thumb);
                }

                // non-text values default to 0 and datetime.minvalue so
                // set the appropriate properties to string.empty

                // Duration
                string strDuration = tag.Duration <= 0
                               ? string.Empty
                               : MediaPortal.Util.Utils.SecondsToHMSString(tag.Duration);
                // Track
                string strTrack = tag.Track <= 0 ? string.Empty : tag.Track.ToString();
                // Year
                string strYear = tag.Year <= 1900 ? string.Empty : tag.Year.ToString();
                // Rating
                string strRating = (Convert.ToDecimal(2 * tag.Rating + 1)).ToString();
                // Bitrate
                string strBitrate = tag.BitRate <= 0 ? string.Empty : tag.BitRate.ToString();
                // Disc ID
                string strDiscID = tag.DiscID <= 0 ? string.Empty : tag.DiscID.ToString();
                // Disc Total
                string strDiscTotal = tag.DiscTotal <= 0 ? string.Empty : tag.DiscTotal.ToString();
                // Times played
                string strTimesPlayed = tag.TimesPlayed <= 0
                                  ? string.Empty
                                  : tag.TimesPlayed.ToString();
                // track total
                string strTrackTotal = tag.TrackTotal <= 0 ? string.Empty : tag.TrackTotal.ToString();
                // BPM
                string strBPM = tag.BPM <= 0 ? string.Empty : tag.BPM.ToString();
                // Channels
                string strChannels = tag.Channels <= 0 ? string.Empty : tag.Channels.ToString();
                // Sample Rate
                string strSampleRate = tag.SampleRate <= 0 ? string.Empty : tag.SampleRate.ToString();
                // Date Last Played
                string strDateLastPlayed = tag.DateTimePlayed == DateTime.MinValue
                                     ? string.Empty
                                     : tag.DateTimePlayed.ToShortDateString();
                // Date Added
                string strDateAdded = tag.DateTimeModified == DateTime.MinValue
                                ? string.Empty
                                : tag.DateTimeModified.ToShortDateString();

                GUIPropertyManager.SetProperty("#Play.Current.Title", tag.Title);
                GUIPropertyManager.SetProperty("#Play.Current.Track", strTrack);
                GUIPropertyManager.SetProperty("#Play.Current.Album", tag.Album);
                GUIPropertyManager.SetProperty("#Play.Current.Artist", tag.Artist);
                GUIPropertyManager.SetProperty("#Play.Current.Genre", tag.Genre);
                GUIPropertyManager.SetProperty("#Play.Current.Year", strYear);
                GUIPropertyManager.SetProperty("#Play.Current.Rating", strRating);
                GUIPropertyManager.SetProperty("#Play.Current.Duration", strDuration);
                GUIPropertyManager.SetProperty("#duration", strDuration);
                GUIPropertyManager.SetProperty("#Play.Current.AlbumArtist", tag.AlbumArtist);
                GUIPropertyManager.SetProperty("#Play.Current.BitRate", strBitrate);
                GUIPropertyManager.SetProperty("#Play.Current.Comment", tag.Comment);
                GUIPropertyManager.SetProperty("#Play.Current.Composer", tag.Composer);
                GUIPropertyManager.SetProperty("#Play.Current.Conductor", tag.Conductor);
                GUIPropertyManager.SetProperty("#Play.Current.DiscID", strDiscID);
                GUIPropertyManager.SetProperty("#Play.Current.DiscTotal", strDiscTotal);
                GUIPropertyManager.SetProperty("#Play.Current.Lyrics", tag.Lyrics);
                GUIPropertyManager.SetProperty("#Play.Current.TimesPlayed", strTimesPlayed);
                GUIPropertyManager.SetProperty("#Play.Current.TrackTotal", strTrackTotal);
                GUIPropertyManager.SetProperty("#Play.Current.FileType", tag.FileType);
                GUIPropertyManager.SetProperty("#Play.Current.Codec", tag.Codec);
                GUIPropertyManager.SetProperty("#Play.Current.BitRateMode", tag.BitRateMode);
                GUIPropertyManager.SetProperty("#Play.Current.BPM", strBPM);
                GUIPropertyManager.SetProperty("#Play.Current.Channels", strChannels);
                GUIPropertyManager.SetProperty("#Play.Current.SampleRate", strSampleRate);
                GUIPropertyManager.SetProperty("#Play.Current.DateLastPlayed", strDateLastPlayed);
                GUIPropertyManager.SetProperty("#Play.Current.DateAdded", strDateAdded);

                var albumInfo = new AlbumInfo();
                if (MusicDatabase.Instance.GetAlbumInfo(tag.Album, tag.AlbumArtist, ref albumInfo))
                {
                    GUIPropertyManager.SetProperty("#Play.AlbumInfo.Review", albumInfo.Review);
                    GUIPropertyManager.SetProperty("#Play.AlbumInfo.Rating", albumInfo.Rating.ToString());
                    GUIPropertyManager.SetProperty("#Play.AlbumInfo.Genre", albumInfo.Genre);
                    GUIPropertyManager.SetProperty("#Play.AlbumInfo.Styles", albumInfo.Styles);
                    GUIPropertyManager.SetProperty("#Play.AlbumInfo.Tones", albumInfo.Tones);
                    GUIPropertyManager.SetProperty("#Play.AlbumInfo.Year", albumInfo.Year.ToString());
                }
                else
                {
                    GUIPropertyManager.SetProperty("#Play.AlbumInfo.Review", String.Empty);
                    GUIPropertyManager.SetProperty("#Play.AlbumInfo.Rating", String.Empty);
                    GUIPropertyManager.SetProperty("#Play.AlbumInfo.Genre", String.Empty);
                    GUIPropertyManager.SetProperty("#Play.AlbumInfo.Styles", String.Empty);
                    GUIPropertyManager.SetProperty("#Play.AlbumInfo.Tones", String.Empty);
                    GUIPropertyManager.SetProperty("#Play.AlbumInfo.Year", String.Empty);
                }
                var artistInfo = new ArtistInfo();
                if (MusicDatabase.Instance.GetArtistInfo(tag.Artist, ref artistInfo))
                {
                    GUIPropertyManager.SetProperty("#Play.ArtistInfo.Bio", artistInfo.AMGBio);
                    GUIPropertyManager.SetProperty("#Play.ArtistInfo.Born", artistInfo.Born);
                    GUIPropertyManager.SetProperty("#Play.ArtistInfo.Genres", artistInfo.Genres);
                    GUIPropertyManager.SetProperty("#Play.ArtistInfo.Instruments", artistInfo.Instruments);
                    GUIPropertyManager.SetProperty("#Play.ArtistInfo.Styles", artistInfo.Styles);
                    GUIPropertyManager.SetProperty("#Play.ArtistInfo.Tones", artistInfo.Tones);
                    GUIPropertyManager.SetProperty("#Play.ArtistInfo.YearsActive", artistInfo.YearsActive);
                }
                else
                {
                    GUIPropertyManager.SetProperty("#Play.ArtistInfo.Bio", String.Empty);
                    GUIPropertyManager.SetProperty("#Play.ArtistInfo.Born", String.Empty);
                    GUIPropertyManager.SetProperty("#Play.ArtistInfo.Genres", String.Empty);
                    GUIPropertyManager.SetProperty("#Play.ArtistInfo.Instruments", String.Empty);
                    GUIPropertyManager.SetProperty("#Play.ArtistInfo.Styles", String.Empty);
                    GUIPropertyManager.SetProperty("#Play.ArtistInfo.Tones", String.Empty);
                    GUIPropertyManager.SetProperty("#Play.ArtistInfo.YearsActive", String.Empty);
                }
            }
            else
            {
                // there is no current track so blank all properties
                GUIPropertyManager.RemovePlayerProperties();
                GUIPropertyManager.SetProperty("#Play.Current.Title", GUILocalizeStrings.Get(4543));
            }
        }