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


C# Song.Clear方法代码示例

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


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

示例1: fetchRandomTracks

    private List<Song> fetchRandomTracks(offlineMode randomMode_)
    {
      int addedSongs = 0;
      MusicDatabase dbs = MusicDatabase.Instance;
      List<Song> randomSongList = new List<Song>(_limitRandomListCount);
      Song randomSong = new Song();
      Song lookupSong = new Song();
      int loops = 0;

      // fetch more than needed since there could be double entries
      while (addedSongs < _limitRandomListCount * 3)
      {
        loops++;
        lookupSong.Clear();

        dbs.GetRandomSong(ref lookupSong);
        randomSong = lookupSong.Clone();

        bool found = false;
        for (int i = 0; i < randomSongList.Count; i++)
        {
          if (randomSongList[i].Artist == randomSong.Artist)
          {
            found = true;
            break;
          }
        }

        if (!found)
        {
          switch (randomMode_)
          {
            case offlineMode.timesplayed:
              if (randomSong.TimesPlayed == 0)
              {
                randomSongList.Add(randomSong);
                addedSongs++;
              }
              break;
            case offlineMode.favorites:
              if (randomSong.Favorite)
              {
                randomSongList.Add(randomSong);
                addedSongs++;
              }
              break;
            case offlineMode.random:
              randomSongList.Add(randomSong);
              addedSongs++;
              break;
          }
        }
        // quick check; 3x rlimit times because every pass could try different artists in dbs.GetRandomSong(ref lookupSong);
        if (loops > 20)
        {
          if (randomMode_ == offlineMode.timesplayed)
          {
            Log.Debug("AudioScrobblerUtils: Not enough unique unheard tracks for random mode");
          }
          break;
        }
      }

      return randomSongList;
    }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:65,代码来源:AudioscrobblerUtils.cs

示例2: GetSongByTitle

    private bool GetSongByTitle(string aTitle, ref Song aSong)
    {
      try
      {
        aSong.Clear();
        string strTitle = aTitle;
        DatabaseUtility.RemoveInvalidChars(ref strTitle);

        string strSQL = String.Format("SELECT * FROM tracks WHERE strTitle LIKE '{0}'", strTitle);

        SQLiteResultSet results = DirectExecute(strSQL);
        if (results.Rows.Count == 0)
        {
          return false;
        }

        if (results.Rows.Count > 1)
        {
          Log.Debug("MusicDatabase: Lookups: GetSongByTitle found multiple results ({0}) for {1}",
                    Convert.ToString(results.Rows.Count), strTitle);
        }

        if (AssignAllSongFieldsFromResultSet(ref aSong, results, 0))
        {
          return true;
        }
      }
      catch (Exception ex)
      {
        Log.Error("musicdatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace);
        Open();
      }

      return false;
    }
开发者ID:djblu,项目名称:MediaPortal-1,代码行数:35,代码来源:MusicDatabase.Lookups.cs

示例3: GetSongByFileName

    public bool GetSongByFileName(string aFileName, ref Song aSong)
    {
      string strFileName = aFileName;

      try
      {
        aSong.Clear();

        DatabaseUtility.RemoveInvalidChars(ref strFileName);

        string strSQL = String.Format("SELECT * FROM tracks WHERE strPath = '{0}'", strFileName);

        SQLiteResultSet results = DirectExecute(strSQL);
        if (results.Rows.Count == 0)
        {
          return false;
        }

        if (AssignAllSongFieldsFromResultSet(ref aSong, results, 0))
        {
          return true;
        }
      }
      catch (Exception ex)
      {
        Log.Error("MusicDatabase: Lookups: GetSongByFileName failed - strFileName: {2} - err:{0} stack:{1}", ex.Message,
                  ex.StackTrace, strFileName);
        Open();
      }

      return false;
    }
开发者ID:djblu,项目名称:MediaPortal-1,代码行数:32,代码来源:MusicDatabase.Lookups.cs

示例4: GetSongByMusicTagInfo

    public bool GetSongByMusicTagInfo(string aArtist, string aAlbum, string aTitle, bool inexactFallback, ref Song aSong)
    {
      //Log.Debug("MusicDatabase: GetSongByMusicTagInfo - Artist: {0}, Album: {1}, Title: {2}, Nearest match: {3}", aArtist, aAlbum, aTitle, Convert.ToString(inexactFallback));
      aSong.Clear();

      // we have all info - try exact
      if (!string.IsNullOrEmpty(aArtist) && !string.IsNullOrEmpty(aAlbum) && !string.IsNullOrEmpty(aTitle))
      {
        if (GetSongByArtistAlbumTitle(aArtist, aAlbum, aTitle, ref aSong))
        {
          return true;
        }
        else if (!inexactFallback)
        {
          return false;
        }
      }

      // An artist may have the same title in different versions (e.g. live, EP) on different discs - therefore this is the 2nd best option
      if (!string.IsNullOrEmpty(aAlbum) && !string.IsNullOrEmpty(aTitle))
      {
        if (GetSongByAlbumTitle(aAlbum, aTitle, ref aSong))
        {
          return true;
        }
        else if (!inexactFallback)
        {
          return false;
        }
      }

      // Maybe the album was spelled different on last.fm or is mistagged in the local collection
      if (!string.IsNullOrEmpty(aArtist) && !string.IsNullOrEmpty(aTitle))
      {
        if (GetSongByArtistTitle(aArtist, aTitle, ref aSong))
        {
          return true;
        }
        else if (!inexactFallback)
        {
          return false;
        }
      }

      // Make sure we get at least one / some usable results
      if (!string.IsNullOrEmpty(aTitle))
      {
        if (GetSongByTitle(aTitle, ref aSong))
        {
          return true;
        }
        else
        {
          return false;
        }
      }

      Log.Debug(
        "MusicDatabase: GetSongByMusicTagInfo did not get usable params! Artist: {0}, Album: {1}, Title: {2}, Nearest Match: {3}",
        aArtist, aAlbum, aTitle, Convert.ToString(inexactFallback));
      return false;
    }
开发者ID:djblu,项目名称:MediaPortal-1,代码行数:62,代码来源:MusicDatabase.Lookups.cs

示例5: GetRandomSong

    public bool GetRandomSong(ref Song aSong)
    {
      try
      {
        aSong.Clear();

        PseudoRandomNumberGenerator rand = new PseudoRandomNumberGenerator();

        int maxIDSong, rndIDSong;
        string strSQL = String.Format("SELECT max(idTrack) FROM tracks");

        SQLiteResultSet results = DirectExecute(strSQL);

        maxIDSong = DatabaseUtility.GetAsInt(results, 0, 0);
        rndIDSong = rand.Next(0, maxIDSong);

        strSQL = String.Format("SELECT * FROM tracks WHERE idTrack={0}", rndIDSong);

        results = DirectExecute(strSQL);
        if (results.Rows.Count > 0)
        {
          if (AssignAllSongFieldsFromResultSet(ref aSong, results, 0))
          {
            return true;
          }
        }
        else
        {
          GetRandomSong(ref aSong);
          return true;
        }
      }
      catch (Exception ex)
      {
        Log.Error("musicdatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace);
        Open();
      }

      return false;
    }
开发者ID:djblu,项目名称:MediaPortal-1,代码行数:40,代码来源:MusicDatabase.Lookups.cs


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