Esempio n. 1
0
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            string coverArtFileName = GUIMusicBaseWindow.GetArtistCoverArtName(artistInfo.Artist);

            Log.Debug("downloading thumbnail for artist: {0}", artistInfo.Artist);
            Util.Utils.DownLoadImage(artistInfo.ImageURL, coverArtFileName);
        }
Esempio n. 2
0
        protected override void OnSort()
        {
            bool isSortable = true;

            isSortable = IsSortableView(handler.View, handler.CurrentLevel);

            if (isSortable)
            {
                // set labels
                for (int i = 0; i < facadeLayout.Count; ++i)
                {
                    GUIListItem item = facadeLayout[i];
                    if (item.IsFolder)
                    {
                        SetSortLabel(ref item, CurrentSortMethod, handler.CurrentLevelWhere);
                    }
                    else
                    {
                        GUIMusicBaseWindow.SetTrackLabels(ref item, CurrentSortMethod);
                    }
                }
                facadeLayout.Sort(new MusicSort(CurrentSortMethod, CurrentSortAsc));
            }

            UpdateButtonStates();
            SelectCurrentItem();

            if (btnSortBy != null)
            {
                btnSortBy.Disabled = !isSortable;
            }
        }
        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();
        }
Esempio n. 4
0
        private void Update()
        {
            if (null == artistInfo)
            {
                return;
            }

            string coverArtFileName = GUIMusicBaseWindow.GetArtistCoverArtName(artistInfo.Artist);

            if (Util.Utils.FileExistsInCache(coverArtFileName))
            {
                GUIPropertyManager.SetProperty("#ArtistInfo.Thumb", coverArtFileName);
            }
            else if (!string.IsNullOrEmpty(artistInfo.ImageURL))
            {
                bw.RunWorkerAsync();
            }

            GUIPropertyManager.SetProperty("#ArtistInfo.Artist", artistInfo.Artist);
            GUIPropertyManager.SetProperty("#ArtistInfo.Bio", artistInfo.AMGBiography);
            GUIPropertyManager.SetProperty("#ArtistInfo.Born", artistInfo.Born);
            GUIPropertyManager.SetProperty("#ArtistInfo.Genres", artistInfo.Genres);
            GUIPropertyManager.SetProperty("#ArtistInfo.Instruments", artistInfo.Instruments);
            GUIPropertyManager.SetProperty("#ArtistInfo.Styles", artistInfo.Styles);
            GUIPropertyManager.SetProperty("#ArtistInfo.Tones", artistInfo.Tones);
            GUIPropertyManager.SetProperty("#ArtistInfo.YearsActive", artistInfo.YearsActive);
            GUIPropertyManager.SetProperty("#ArtistInfo.Albums", artistInfo.Albums);
            GUIPropertyManager.SetProperty("#ArtistInfo.Compilations", artistInfo.Compilations);
            GUIPropertyManager.SetProperty("#ArtistInfo.Singles", artistInfo.Singles);
            GUIPropertyManager.SetProperty("#ArtistInfo.MiscAlbums", artistInfo.Misc);
        }
Esempio n. 5
0
        private void UpdateSimilarTrackWorker(string filename, MusicTag tag)
        {
            if (tag == null)
            {
                return;
            }

            lstSimilarTracks.Clear();

            List <LastFMSimilarTrack> tracks;

            try
            {
                Log.Debug("GUIMusicPlayingNow: Calling Last.FM to get similar Tracks");
                tracks = LastFMLibrary.GetSimilarTracks(tag.Title, tag.Artist);
            }
            catch (Exception ex)
            {
                Log.Error("Error getting similar tracks in now playing");
                Log.Error(ex);
                return;
            }

            Log.Debug("GUIMusicPlayingNow: Number of similar tracks returned from Last.FM: {0}", tracks.Count);

            var dbTracks = GetSimilarTracksInDatabase(tracks);

            for (var i = 0; i < 3; i++)
            {
                if (dbTracks.Count > 0)
                {
                    var trackNo = Randomizer.Next(0, dbTracks.Count);
                    var song    = dbTracks[trackNo];

                    var t    = song.ToMusicTag();
                    var item = new GUIListItem
                    {
                        AlbumInfoTag = song,
                        MusicTag     = tag,
                        IsFolder     = false,
                        Label        = song.Title,
                        Path         = song.FileName
                    };
                    item.AlbumInfoTag = song;
                    item.MusicTag     = t;

                    GUIMusicBaseWindow.SetTrackLabels(ref item, MusicSort.SortMethod.Album);
                    dbTracks.RemoveAt(trackNo); // remove song after adding to playlist to prevent the same sone being added twice

                    if (g_Player.currentFileName != filename)
                    {
                        return;                             // track has changed since request so ignore
                    }
                    lstSimilarTracks.Add(item);
                }
            }
            Log.Debug("GUIMusicPlayingNow: Tracks returned after matching Last.FM results with database tracks: {0}", lstSimilarTracks.Count);
        }
Esempio n. 6
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);
            }
        }
Esempio n. 7
0
        private void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                return;
            }
            string coverArtFileName = GUIMusicBaseWindow.GetArtistCoverArtName(artistInfo.Artist);

            if (Util.Utils.FileExistsInCache(coverArtFileName))
            {
                GUIPropertyManager.SetProperty("#ArtistInfo.Thumb", coverArtFileName);
            }
        }
Esempio n. 8
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();
        }
Esempio n. 9
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();
                }
            }
        }
Esempio n. 10
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;
            }
        }
Esempio n. 11
0
        /// <summary>
        /// this is actually loading a database view not a directory
        /// and this is done via view handler so parameter is not used
        /// but is needed to override method in base class
        /// </summary>
        /// <param name="strNotUsed">Used to implement method in base class but not used</param>
        protected override void LoadDirectory(string strNotUsed)
        {
            GUIWaitCursor.Show();
            GUIListItem SelectedItem = facadeLayout.SelectedListItem;

            int    previousLevel   = ((MusicViewHandler)handler).PreviousLevel;
            string strSelectedItem = string.Empty;

            if (SelectedItem != null)
            {
                // if there is an item selected and we are loading a new view
                // then store the existing value so when we navigate back up through
                // the view levels we can focus on the item we had selected
                // we can not use current level in the name for the directory history
                // as current level gets updated before LoadDirectory is called
                // therefore use previous level which is set by the music view handler
                // when that returns (ie. that will be level of the view user has
                // made selection from as it has not been cleared yet)
                if (SelectedItem.IsFolder && SelectedItem.Label != "..")
                {
                    m_history.Set(SelectedItem.Label, handler.LocalizedCurrentView + "." +
                                  previousLevel.ToString());
                }
            }

            List <Song> songs;

            if (!((MusicViewHandler)handler).Execute(out songs))
            {
                GUIWaitCursor.Hide();
                Action action = new Action();
                action.wID = Action.ActionType.ACTION_PREVIOUS_MENU;
                GUIGraphicsContext.OnAction(action);
                return;
            }

            GUIControl.ClearControl(GetID, facadeLayout.GetID);
            SwitchLayout();

            List <GUIListItem> itemsToAdd = new List <GUIListItem>();

            TimeSpan totalPlayingTime = new TimeSpan();

            if (previousLevel > handler.CurrentLevel)
            {
                // only need to lookup values when navigating back up through the view
                strSelectedItem = m_history.Get(handler.LocalizedCurrentView + "." + handler.CurrentLevel.ToString());
            }

            #region handle pin protected share

            if (songs.Count > 0) // some songs in there?
            {
                Song song = songs[0];
                if (song.FileName.Length > 0) // does a filename exits
                {
                    foreach (Share share in _shareList)
                    {
                        if (song.FileName.Contains(share.Path)) // compare it with shares
                        {
                            if (share.Pincode != string.Empty)  // does it have a pincode?
                            {
                                GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GET_PASSWORD, 0, 0, 0, 0, 0, 0);
                                GUIWindowManager.SendMessage(msg); // ask for the userinput

                                if (msg.Label != share.Pincode)
                                {
                                    songs.Clear();
                                }
                                break;
                            }
                        }
                    }
                }
            }

            #endregion

            if (handler.CurrentLevel > 0)
            {
                // add ".." folder item if not at bottom level of view
                GUIListItem pItem = new GUIListItem("..");
                pItem.Path     = string.Empty;
                pItem.IsFolder = true;
                Util.Utils.SetDefaultIcons(pItem);
                itemsToAdd.Add(pItem);
            }

            // Get current Filter used
            var currentFilter = (FilterDefinition)handler.View.Filters[handler.CurrentLevel];

            for (int i = 0; i < songs.Count; ++i)
            {
                Song        song = songs[i];
                GUIListItem item = new GUIListItem();

                MusicTag tag = new MusicTag();
                tag = song.ToMusicTag();
                item.AlbumInfoTag = song;
                item.MusicTag     = tag;

                if (handler.CurrentLevel + 1 < handler.MaxLevels)
                {
                    item.IsFolder = true;
                    item.Label    = MusicViewHandler.GetFieldValue(song, handler.CurrentLevelWhere);

                    // If we are grouping on a specific value, we have in the Duration field the number of items
                    // Use this in the sort field
                    if (currentFilter.SqlOperator == "group")
                    {
                        item.Label2 = tag.Duration.ToString();
                    }
                    else
                    {
                        SetSortLabel(ref item, CurrentSortMethod, handler.CurrentLevelWhere);
                    }
                }
                else
                {
                    item.IsFolder = false;
                    if (!GUIMusicBaseWindow.SetTrackLabels(ref item, CurrentSortMethod))
                    {
                        item.Label = song.Title;
                    }
                }

                if (tag != null)
                {
                    if (tag.Duration > 0)
                    {
                        totalPlayingTime = totalPlayingTime.Add(new TimeSpan(0, 0, tag.Duration));
                    }
                }

                item.Path = song.FileName;

                if (!string.IsNullOrEmpty(_currentPlaying) &&
                    item.Path.Equals(_currentPlaying, StringComparison.OrdinalIgnoreCase))
                {
                    item.Selected = true;
                }

                item.Duration        = song.Duration;
                tag.TimesPlayed      = song.TimesPlayed;
                item.Rating          = song.Rating;
                item.Year            = song.Year;
                item.OnRetrieveArt  += new GUIListItem.RetrieveCoverArtHandler(OnRetrieveCoverArt);
                item.OnItemSelected += new GUIListItem.ItemSelectedHandler(item_OnItemSelected);
                itemsToAdd.Add(item);
            }

            itemsToAdd.Sort(new MusicSort(CurrentSortMethod, CurrentSortAsc));

            int  iItem        = 0; // used to hold index of item to select
            bool itemSelected = false;
            for (int i = 0; i < itemsToAdd.Count; ++i)
            {
                if (!itemSelected && itemsToAdd[i].Label == strSelectedItem)
                {
                    iItem        = i;
                    itemSelected = true;
                }
                facadeLayout.Add(itemsToAdd[i]);
            }

            int iTotalItems = facadeLayout.Count;
            if (iTotalItems > 0)
            {
                GUIListItem rootItem = facadeLayout[0];
                if (rootItem.Label == "..")
                {
                    iTotalItems--;
                }
            }

            //set object count label, total duration
            GUIPropertyManager.SetProperty("#itemcount", Util.Utils.GetObjectCountLabel(iTotalItems));

            if (totalPlayingTime.TotalSeconds > 0)
            {
                GUIPropertyManager.SetProperty("#totalduration",
                                               Util.Utils.SecondsToHMSString((int)totalPlayingTime.TotalSeconds));
            }
            else
            {
                GUIPropertyManager.SetProperty("#totalduration", string.Empty);
            }

            if (itemSelected)
            {
                GUIControl.SelectItemControl(GetID, facadeLayout.GetID, iItem);
            }
            else if (m_iItemSelected >= 0)
            {
                GUIControl.SelectItemControl(GetID, facadeLayout.GetID, m_iItemSelected);
            }
            else
            {
                SelectCurrentItem();
            }

            UpdateButtonStates();
            GUIWaitCursor.Hide();
        }
        private void GetCoverArtList(string folderPath, ref int albumCount, ref int curCount, bool skipIfCoverartExist,
                                     ref List <Song> songs)
        {
            DirectoryInfo dirInfo = new DirectoryInfo(folderPath);

            FileSystemInfo[] fsInfos = dirInfo.GetFileSystemInfos();
            bool             foundTrackForThisDir = false;
            bool             skippingAlbum        = false;

            foreach (FileSystemInfo fsi in fsInfos)
            {
                try
                {
                    CheckForAppShutdown();

                    if (_Abort || _AbortedByUser || GUICoverArtGrabberResults.CancelledByUser)
                    {
                        break;
                    }

                    // Is it a DirectoryInfo object...
                    if (fsi is DirectoryInfo)
                    {
                        //curCount++;
                        foundTrackForThisDir = false;

                        // Iterate through all sub-directories.
                        GetCoverArtList(fsi.FullName, ref albumCount, ref curCount, skipIfCoverartExist, ref songs);
                    }

                    // ...or a FileInfo object?
                    else if (fsi is FileInfo)
                    {
                        // Have we already processed a track for this folder
                        // and if so, is it an audio file?
                        if (foundTrackForThisDir || !Util.Utils.IsAudio(fsi.FullName))
                        {
                            continue;
                        }

                        string        path  = Path.GetDirectoryName(fsi.FullName);
                        DirectoryInfo di    = new DirectoryInfo(path);
                        FileInfo[]    files = null;

                        if (di != null)
                        {
                            files = di.GetFiles();
                        }

                        string artist              = string.Empty;
                        bool   isCompilation       = false;
                        int    difArtistCount      = 0;
                        int    foundAudioFileCount = 0;

                        MusicTag tag  = null;
                        Song     song = null;

                        for (int i = 0; i < files.Length; i++)
                        {
                            if (foundAudioFileCount > 0)
                            {
                                break;
                            }

                            song = null;
                            tag  = null;

                            string curTrackPath = files[i].FullName;

                            if (!Util.Utils.IsAudio(curTrackPath))
                            {
                                continue;
                            }

                            foundAudioFileCount++;
                            song = new Song();
                            if (_MusicDatabase.GetSongByFileName(curTrackPath, ref song))
                            {
                                // Make sure the the returned song has a valid file path
                                if (song.FileName.Length == 0)
                                {
                                    song.FileName = curTrackPath;
                                }

                                if (artist == string.Empty)
                                {
                                    artist = song.Artist;
                                    continue;
                                }

                                if (artist.ToLower().CompareTo(song.Artist.ToLower()) != 0)
                                {
                                    difArtistCount++;
                                }
                            }

                            else
                            {
                                song = null;
                                tag  = TagReader.TagReader.ReadTag(curTrackPath);

                                if (tag != null)
                                {
                                    if (artist == string.Empty)
                                    {
                                        artist = tag.Artist;
                                        continue;
                                    }

                                    if (artist.ToLower().CompareTo(tag.Artist.ToLower()) != 0)
                                    {
                                        difArtistCount++;
                                    }
                                }
                            }
                        }

                        if (difArtistCount > 0)
                        {
                            isCompilation = true;
                        }

                        if (song == null)
                        {
                            if (tag != null)
                            {
                                song          = new Song();
                                song.FileName = fsi.FullName;
                                song.Album    = tag.Album;

                                if (isCompilation)
                                {
                                    song.Artist = "";
                                }

                                song.Artist = tag.Artist;
                                song.Title  = tag.Title;
                                song.Track  = tag.Track;
                            }
                        }

                        if (song != null)
                        {
                            curCount++;

                            //Log.Info("Cover art grabber:updating status for {0}", song.Album);
                            UpdateAlbumScanProgress(song.Album, albumCount, curCount);
                            foundTrackForThisDir = true;

                            if (_SkipIfCoverArtExists &&
                                GUIMusicBaseWindow.CoverArtExists(song.Artist, song.Album, song.FileName, _SaveImageToAlbumFolder))
                            {
                                continue;
                            }

                            if (skippingAlbum)
                            {
                                continue;
                            }

                            songs.Add(song);
                        }
                    }
                }

                catch (Exception ex)
                {
                    Log.Info("Cover art grabber exception:{0}", ex.ToString());
                    continue;
                }
            }
        }
Esempio n. 13
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);
            }
        }
Esempio n. 14
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));
            }
        }