当前位置: 首页>>代码示例>>C#>>正文


C# Song.ToMusicTag方法代码示例

本文整理汇总了C#中MediaPortal.Music.Database.Song.ToMusicTag方法的典型用法代码示例。如果您正苦于以下问题:C# Song.ToMusicTag方法的具体用法?C# Song.ToMusicTag怎么用?C# Song.ToMusicTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MediaPortal.Music.Database.Song的用法示例。


在下文中一共展示了Song.ToMusicTag方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddSongToPlaylist

    /// <summary>
    /// Add or enque a song to the current playlist - call OnSongInserted() after this!!!
    /// </summary>
    /// <param name="song">the song to add</param>
    /// <returns>if the action was successful</returns>
    private bool AddSongToPlaylist(ref Song song)
    {
      PlayList playlist;
      if (PlaylistPlayer.CurrentPlaylistType == PlayListType.PLAYLIST_MUSIC_TEMP)
      {
        playlist = PlaylistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC_TEMP);
      }
      else
      {
        playlist = PlaylistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC);
      }
      
      if (playlist == null)
      {
        return false;
      }

      //add to playlist
      PlayListItem playlistItem = new PlayListItem();
      playlistItem.Type = PlayListItem.PlayListItemType.Audio;
      StringBuilder sb = new StringBuilder();

      playlistItem.FileName = song.FileName;
      sb.Append(song.Track);
      sb.Append(". ");
      sb.Append(song.Artist);
      sb.Append(" - ");
      sb.Append(song.Title);
      playlistItem.Description = sb.ToString();
      playlistItem.Duration = song.Duration;

      playlistItem.MusicTag = song.ToMusicTag();
      playlist.Add(playlistItem);

      OnSongInserted();
      return true;
    }
开发者ID:cmendozac,项目名称:MediaPortal-1,代码行数:42,代码来源:GUIMusicPlayingNow.cs

示例2: LoadPlayList

    protected void LoadPlayList(string strPlayList, bool startPlayback, bool isAsynch, bool defaultLoad)
    {
      IPlayListIO loader = PlayListFactory.CreateIO(strPlayList);
      if (loader == null)
      {
        return;
      }

      PlayList playlist = new PlayList();

      if (!Util.Utils.FileExistsInCache(strPlayList))
      {
        Log.Info("Playlist: Skipping non-existing Playlist file: {0}", strPlayList);
        return;
      }

      if (!loader.Load(playlist, strPlayList))
      {
        if (isAsynch && defaultLoad) // we might not be in GUI yet! we have asynch and default load because we might want to use asynch loading from gui button too, later!
          throw new Exception(string.Format("Unable to load Playlist file: {0}", strPlayList)); // exception is handled in backgroundworker
        else
          TellUserSomethingWentWrong();
        return;
      }

      if (_autoShuffleOnLoad)
      {
        playlist.Shuffle();
      }

      playlistPlayer.CurrentPlaylistName = Path.GetFileNameWithoutExtension(strPlayList);
      if (playlist.Count == 1 && startPlayback)
      {
        Log.Info("GUIMusic:Play: play single playlist item - {0}", playlist[0].FileName);
        // Default to type Music, when a playlist has been selected from My Music
        g_Player.Play(playlist[0].FileName, g_Player.MediaType.Music);
        return;
      }

      if (null != bw && isAsynch && bw.CancellationPending)
        return;

      // clear current playlist
      //playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC).Clear();

      Song song = new Song();
      PlayList newPlaylist = new PlayList();

      // add each item of the playlist to the playlistplayer
      for (int i = 0; i < playlist.Count; ++i)
      {
        if (null != bw && isAsynch && bw.CancellationPending)
          return;

        PlayListItem playListItem = playlist[i];
        m_database.GetSongByFileName(playListItem.FileName, ref song);
        MusicTag tag = new MusicTag();
        tag = song.ToMusicTag();
        playListItem.MusicTag = tag;
        if (Util.Utils.FileExistsInCache(playListItem.FileName) ||
            playListItem.Type == PlayListItem.PlayListItemType.AudioStream)
        {
          newPlaylist.Add(playListItem);
        }
        else
        {
          Log.Info("Playlist: File {0} no longer exists. Skipping item.", playListItem.FileName);
        }
      }

      if (null != bw && isAsynch && bw.CancellationPending)
        return;

      ReplacePlaylist(newPlaylist);

      if (startPlayback)
        StartPlayingPlaylist();
    }
开发者ID:nio22,项目名称:MediaPortal-1,代码行数:78,代码来源:GUIMusicBaseWindow.cs

示例3: AddRandomSongToPlaylist

    private bool AddRandomSongToPlaylist(ref Song song)
    {
      //check duplication
      PlayList playlist = playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC);
      for (int i = 0; i < playlist.Count; i++)
      {
        PlayListItem item = playlist[i];
        if (item.FileName == song.FileName)
        {
          return false;
        }
      }

      //add to playlist
      PlayListItem playlistItem = new PlayListItem();
      playlistItem.Type = PlayListItem.PlayListItemType.Audio;
      StringBuilder sb = new StringBuilder();

      playlistItem.FileName = song.FileName;
      sb.Append(song.Track);
      sb.Append(". ");
      sb.Append(song.Artist);
      sb.Append(" - ");
      sb.Append(song.Title);
      playlistItem.Description = sb.ToString();
      playlistItem.Duration = song.Duration;

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

      playlistItem.MusicTag = tag;

      playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC).Add(playlistItem);
      return true;
    }
开发者ID:akhilgt,项目名称:MediaPortal-1,代码行数:35,代码来源:GUIMusicPlaylist.cs

示例4: AddRandomSongToPlaylist

        bool AddRandomSongToPlaylist(ref Song song, ref YouTubeFeed vidr)
        {
            //check duplication
            PlayList playlist = playlistPlayer.GetPlaylist(_playlistType);
            for (int i = 0; i < playlist.Count; i++)
            {
                PlayListItem item = playlist[i];
                if (item.FileName == song.FileName)
                    return false;
            }

            //add to playlist
            PlayListItem playlistItem = new PlayListItem();
            playlistItem.Type = PlayListItem.PlayListItemType.Video; //Playlists.PlayListItem.PlayListItemType.Audio;
            StringBuilder sb = new StringBuilder();

            playlistItem.FileName = song.FileName;
            //sb.Append(song.Track);
            //sb.Append(". ");
            sb.Append(song.Artist);
            if (!string.IsNullOrEmpty(song.Title))
            {
                sb.Append(" - ");
                sb.Append(song.Title);
            }
            playlistItem.Description = sb.ToString();
            playlistItem.Duration = song.Duration;

            MusicTag tag = new MusicTag();
            tag = song.ToMusicTag();
            foreach (YouTubeEntry entry in vidr.Entries)
            {
                if (Youtube2MP.PlaybackUrl(entry) == playlistItem.FileName)
                {
                    playlistItem.MusicTag = entry;
                    if (!Youtube2MP._settings.UseYouTubePlayer)
                    {
                        playlistItem.FileName = Youtube2MP.StreamPlaybackUrl(entry, new VideoInfo());
                    }
                }
            }

            playlistPlayer.GetPlaylist(_playlistType).Add(playlistItem);
            return true;
        }
开发者ID:andrewjswan,项目名称:youtube-fm-for-mediaportal,代码行数:45,代码来源:YouTubeGUIPlaylist.cs

示例5: OnRetrieveMusicInfo

 void OnRetrieveMusicInfo(ref List<GUIListItem> items)
 {
     if (items.Count <= 0)
         return;
     MusicDatabase dbs = MusicDatabase.Instance;
     Song song = new Song();
     foreach (GUIListItem item in items)
     {
         if (item.MusicTag == null)
         {
             if (dbs.GetSongByFileName(item.Path, ref song))
             {
                 MusicTag tag = new MusicTag();
                 tag = song.ToMusicTag();
                 item.MusicTag = tag;
             }
             //else
             //  if (UseID3)
             //  {
             //    item.MusicTag = TagReader.TagReader.ReadTag(item.Path);
             //  }
         }
     }
 }
开发者ID:andrewjswan,项目名称:youtube-fm-for-mediaportal,代码行数:24,代码来源:YouTubeGUIPlaylist.cs

示例6: OnPlaybackChangedOrStopped

    /// <summary>
    /// Invoked when a song is Stopped or Changed to next song
    /// If "Resume" is configured and the meta matches the resume settings then the Resume time is stored in the DB
    /// </summary>
    /// <param name="type"></param>
    /// <param name="stoptime"></param>
    /// <param name="filename"></param>
    void OnPlaybackChangedOrStopped(g_Player.MediaType type, int stoptime, string filename)
    {
      if (type != g_Player.MediaType.Music)
      {
        return;
      }

      if (_resumeEnabled)
      {
        Song song = new Song();
        // We might have reached the end of a song, then clear the resumeAt time
        m_database.GetSongByFileName(filename, ref song);
        int endTime = song.Duration - MusicPlayer.BASS.Config.CrossFadeIntervalMs / 1000;
        if (song.Id > -1 && (endTime == stoptime || stoptime < _resumeAfter && song.ResumeAt > 0))
        {
          song.ResumeAt = 0;
          m_database.SetResume(song);
          return;
        }

        if (stoptime > _resumeAfter)
        {
          Log.Info("GUIMusic: Song stopped at {0} seconds with resume support enabled", stoptime);
          if (_resumeSelect.Length > 0)
          {
            MusicTag tag = null;
            // We found a valid song, if the id is > -1
            if (song.Id > -1)
            {
              tag = song.ToMusicTag();
            }
            else
            {
              // read tag from file
              tag = m_database.GetTag(filename);
            }

            string value = "";
            switch (_resumeSelect)
            {
              case "Genre":
                value = tag.Genre;
                break;

              case "Title":
                value = tag.Title;
                break;

              case "Filename":
                value = tag.FileName;
                break;

              case "Album":
                value = tag.Album;
                break;

              case "Artist":
                value = tag.Artist;
                break;

              case "AlbumArtist":
                value = tag.AlbumArtist;
                break;

              case "Composer":
                value = tag.Composer;
                break;

              case "Conductor":
                value = tag.Conductor;
                break;
            }

            if (!value.Contains(_resumeSearch))
            {
              Log.Info("GUIMusic: Tags not matching selection criteria. No resumetime stored.");
              return;
            }
          }

          if (song.Id == -1)
          {
            // No Song found. Let's add it to the database and then retrieve it
            Log.Debug("GUIMusic: Song not found in database. Add to database");
            m_database.AddSong(filename);
            m_database.GetSongByFileName(filename, ref song);
          }

          song.ResumeAt = stoptime;
          m_database.SetResume(song);
        }
      }
    }
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:100,代码来源:GUIMusicBaseWindow.cs

示例7: ToPlayListItem

        /// <summary>
        /// Returns a playlistitem from a song
        /// 
        /// Note: this method is available in MediaPortal 1.2 in 
        /// MediaPortal.Music.Database.Song.ToPlayListItem()
        /// 
        /// As it wasn't available in 1.1.3 this was copied to a private method
        /// TODO: Remove this once 1.2 has become stable and 1.1.3 is not needed anymore
        /// </summary>
        /// <param name="song">Song</param>
        /// <returns>Playlistitem from a song</returns>
        internal static PlayListItem ToPlayListItem(Song song)
        {
            PlayListItem pli = new PlayListItem();

            pli.Type = PlayListItem.PlayListItemType.Audio;
            pli.FileName = song.FileName;
            pli.Description = song.Title;
            pli.Duration = song.Duration;
            pli.MusicTag = song.ToMusicTag();

            return pli;
        }
开发者ID:Kucheek,项目名称:WifiRemote,代码行数:23,代码来源:PlaylistHelper.cs

示例8: AddStreamSongToPlaylist

    private bool AddStreamSongToPlaylist(ref Song song)
    {
      PlayList playlist = PlaylistPlayer.GetPlaylist(PlayListType.PLAYLIST_RADIO_STREAMS);
      if (playlist == null || song == null)
      {
        return false;
      }

      // We only want one item at each time since the links invalidate and therefore 
      // automatic advancement of playlist items does not make any sense.
      playlist.Clear();

      //add to playlist
      PlayListItem playlistItem = new PlayListItem();
      playlistItem.Type = PlayListItem.PlayListItemType.Audio;
      StringBuilder sb = new StringBuilder();

      playlistItem.FileName = song.URL;

      sb.Append(song.Artist);
      sb.Append(" - ");
      sb.Append(song.Title);
      playlistItem.Description = sb.ToString();
      playlistItem.Duration = song.Duration;

      playlistItem.MusicTag = song.ToMusicTag();

      playlist.Add(playlistItem);

      return true;
    }
开发者ID:sekotin,项目名称:MediaPortal-1,代码行数:31,代码来源:GUIRadioLastFM.cs

示例9: AddItemToFacadeControl

    private void AddItemToFacadeControl(Song aSong)
    {
      GUIListItem item = new GUIListItem(aSong.ToShortString());
      item.Label = aSong.Artist + " - " + aSong.Title;

      string iconThumb = InfoScrobbler.GetSongAlbumImage(aSong);
      item.ThumbnailImage = item.IconImage = item.IconImageBig = iconThumb;
      item.MusicTag = aSong.ToMusicTag();

      facadeRadioPlaylist.Add(item);
    }
开发者ID:sekotin,项目名称:MediaPortal-1,代码行数:11,代码来源:GUIRadioLastFM.cs

示例10: LoadFacade

    private void LoadFacade()
    {
      TimeSpan totalPlayingTime = new TimeSpan();
      PlayList pl = playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC);
      Song song = new Song();

      if (facadeLayout != null)
      {
        facadeLayout.Clear();
      }

      for (int i = 0; i < pl.Count; i++)
      {
        PlayListItem pi = pl[i];
        if (PlayListFactory.IsPlayList(pi.FileName))
        {
          pl.Remove(pi.FileName, false);
          LoadPlayList(pi.FileName, false, false, false, false);
        }
        // refresh pi if .m3u are cleaned up
        pi = pl[i];
        GUIListItem pItem = new GUIListItem(pi.Description);
        MusicTag tag = new MusicTag();
        if (m_database.GetSongByFileName(pi.FileName, ref song))
        {
          tag = song.ToMusicTag();
          pi.MusicTag = tag;
        }
        else
        {
          tag = TagReader.TagReader.ReadTag(pi.FileName);
          pi.MusicTag = tag;
        }
        bool dirtyTag = false;
        if (tag != null)
        {
          pItem.MusicTag = tag;
          if (tag.Title == ("unknown") || tag.Title.IndexOf("unknown") > 0 || tag.Title == string.Empty)
          {
            dirtyTag = true;
          }
        }
        else
        {
          dirtyTag = true;
        }

        if (tag != null && !dirtyTag)
        {
          int playCount = tag.TimesPlayed;
          string duration = Util.Utils.SecondsToHMSString(tag.Duration);
          pItem.Label = string.Format("{0} - {1}", tag.Artist, tag.Title);
          pItem.Label2 = duration;
          pItem.MusicTag = pi.MusicTag;
        }

        pItem.Path = pi.FileName;
        pItem.IsFolder = false;

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

        if (pi.Played)
        {
          pItem.Shaded = true;
        }

        Util.Utils.SetDefaultIcons(pItem);

        pItem.OnRetrieveArt += new GUIListItem.RetrieveCoverArtHandler(OnRetrieveCoverArt);
        pItem.OnItemSelected += new GUIListItem.ItemSelectedHandler(item_OnItemSelected);

        facadeLayout.Add(pItem);
      }

      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);
      }

//.........这里部分代码省略.........
开发者ID:Eddie-Jee,项目名称:MediaPortal-1,代码行数:101,代码来源:GUIMusicPlaylist.cs


注:本文中的MediaPortal.Music.Database.Song.ToMusicTag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。