コード例 #1
0
ファイル: karaokelyrics.cpp プロジェクト: Distrotech/xbmc
void CKaraokeLyrics::initData( const std::string & songPath )
{
  m_songPath = songPath;

  // Reset AV delay
  m_avOrigDelay = m_avDelay = 0;

  // Get song ID if available
  m_idSong = 0;
  CMusicDatabase musicdatabase;

  // Get song-specific delay from the database
  if ( g_advancedSettings.m_karaokeKeepDelay && musicdatabase.Open() )
  {
    CSong song;
    if ( musicdatabase.GetSongByFileName( songPath, song) )
    {
      m_idSong = song.idSong;
      if ( song.iKaraokeDelay != 0 )
      {
        m_avOrigDelay = m_avDelay = (double) song.iKaraokeDelay / 10.0;
        CLog::Log( LOGDEBUG, "Karaoke timing correction: restored lyrics delay from database to %g", m_avDelay );
      }
    }

    musicdatabase.Close();
  }
}
コード例 #2
0
ファイル: AudioLibrary.cpp プロジェクト: SunSeosahai/xbmc
bool CAudioLibrary::FillFileItem(const CStdString &strFilename, CFileItem &item)
{
  CMusicDatabase musicdatabase;
  if (strFilename.empty() || !musicdatabase.Open())
    return false;

  if (CDirectory::Exists(strFilename))
  {
    CAlbum album;
    int albumid = musicdatabase.GetAlbumIdByPath(strFilename);
    if (!musicdatabase.GetAlbumInfo(albumid, album, NULL))
      return false;

    item = CFileItem(strFilename, album);
  }
  else
  {
    CSong song;
    if (!musicdatabase.GetSongByFileName(strFilename, song))
      return false;

    item = CFileItem(song);
  }

  return true;
}
コード例 #3
0
ファイル: AudioLibrary.cpp プロジェクト: BigNoid/xbmc
bool CAudioLibrary::FillFileItem(const std::string &strFilename, CFileItemPtr &item, const CVariant &parameterObject /* = CVariant(CVariant::VariantTypeArray) */)
{
  CMusicDatabase musicdatabase;
  if (strFilename.empty())
    return false;

  bool filled = false;
  if (musicdatabase.Open())
  {
    if (CDirectory::Exists(strFilename))
    {
      CAlbum album;
      int albumid = musicdatabase.GetAlbumIdByPath(strFilename);
      if (musicdatabase.GetAlbum(albumid, album, false))
      {
        item->SetFromAlbum(album);
        FillItemArtistIDs(album.GetArtistIDArray(), item);

        CFileItemList items;
        items.Add(item);

        if (GetAdditionalAlbumDetails(parameterObject, items, musicdatabase) == OK)
          filled = true;
      }
    }
    else
    {
      CSong song;
      if (musicdatabase.GetSongByFileName(strFilename, song))
      {
        item->SetFromSong(song);
        FillItemArtistIDs(song.GetArtistIDArray(), item);

        CFileItemList items;
        items.Add(item);
        if (GetAdditionalSongDetails(parameterObject, items, musicdatabase) == OK)
          filled = true;
      }
    }
  }

  if (item->GetLabel().empty())
  {
    item->SetLabel(CUtil::GetTitleFromPath(strFilename, false));
    if (item->GetLabel().empty())
      item->SetLabel(URIUtils::GetFileName(strFilename));
  }

  return filled;
}
コード例 #4
0
bool CAudioLibrary::FillFileItem(const CStdString &strFilename, CFileItem &item)
{
  CMusicDatabase musicdatabase;
  bool status = false;
  if (!strFilename.empty() && !CDirectory::Exists(strFilename) && musicdatabase.Open())
  {
    CSong song;
    if (musicdatabase.GetSongByFileName(strFilename, song))
    {
      item = CFileItem(song);
      status = true;
    }

    musicdatabase.Close();
  }

  return status;
}
コード例 #5
0
ファイル: AudioLibrary.cpp プロジェクト: AFFLUENTSOCIETY/SPMC
bool CAudioLibrary::FillFileItem(const CStdString &strFilename, CFileItemPtr &item, const CVariant &parameterObject /* = CVariant(CVariant::VariantTypeArray) */)
{
  CMusicDatabase musicdatabase;
  if (strFilename.empty() || !musicdatabase.Open())
    return false;

  if (CDirectory::Exists(strFilename))
  {
    CAlbum album;
    int albumid = musicdatabase.GetAlbumIdByPath(strFilename);
    if (!musicdatabase.GetAlbumInfo(albumid, album, NULL))
      return false;

    item->SetFromAlbum(album);

    CFileItemList items;
    items.Add(item);
    if (GetAdditionalAlbumDetails(parameterObject, items, musicdatabase) != OK)
      return false;
  }
  else
  {
    CSong song;
    if (!musicdatabase.GetSongByFileName(strFilename, song))
      return false;

    item->SetFromSong(song);

    CFileItemList items;
    items.Add(item);
    if (GetAdditionalSongDetails(parameterObject, items, musicdatabase) != OK)
      return false;
  }

  if (item->GetLabel().empty())
    item->SetLabel(CUtil::GetTitleFromPath(strFilename, false));
  if (item->GetLabel())
    item->SetLabel(URIUtils::GetFileName(strFilename));

  return true;
}
コード例 #6
0
ファイル: LastFmManager.cpp プロジェクト: SunSeosahai/xbmc
bool CLastFmManager::Love(const CMusicInfoTag& musicinfotag)
{
  if (!IsLastFmEnabled())
  {
    CLog::Log(LOGERROR, "LastFmManager Love, lastfm is not enabled.");
    return false;
  }

  CStdString strTitle = musicinfotag.GetTitle();
  CStdString strArtist = StringUtils::Join(musicinfotag.GetArtist(), g_advancedSettings.m_musicItemSeparator);

  CStdString strFilePath;
  if (m_CurrentSong.CurrentSong && !m_CurrentSong.CurrentSong->IsLastFM())
  {
    //path to update the rating for
    strFilePath = m_CurrentSong.CurrentSong->GetPath();
  }
  if (CallXmlRpc("loveTrack",strArtist, strTitle))
  {
    m_CurrentSong.IsLoved = true;
    //update the rating to 5, we loved it.
    CMusicInfoTag newTag(musicinfotag);
    newTag.SetRating('5');
    CApplicationMessenger::Get().SetCurrentSongTag(newTag);
    //try updating the rating in the database if it's a local file.
    CMusicDatabase musicdatabase;
    if (musicdatabase.Open())
    {
      CSong song;
      //update if the song exists in our database and there is no rating yet.
      if (musicdatabase.GetSongByFileName(strFilePath, song) && song.rating == '0')
      {
        musicdatabase.SetSongRating(strFilePath, '5');
      }
      musicdatabase.Close();
    }
    return true;
  }
  return false;
}
コード例 #7
0
ファイル: AnnouncementManager.cpp プロジェクト: ugers/xbmc
void CAnnouncementManager::Announce(AnnouncementFlag flag, const char *sender, const char *message, CFileItemPtr item, CVariant &data)
{
    if (!item.get())
    {
        Announce(flag, sender, message, data);
        return;
    }

    // Extract db id of item
    CVariant object = data.isNull() || data.isObject() ? data : CVariant::VariantTypeObject;
    CStdString type;
    int id = 0;

    if(item->HasPVRChannelInfoTag())
    {
        const PVR::CPVRChannel *channel = item->GetPVRChannelInfoTag();
        id = channel->ChannelID();
        type = "channel";

        object["item"]["title"] = channel->ChannelName();
        object["item"]["channeltype"] = channel->IsRadio() ? "radio" : "tv";

        if (data.isMember("player") && data["player"].isMember("playerid"))
            object["player"]["playerid"] = channel->IsRadio() ? PLAYLIST_MUSIC : PLAYLIST_VIDEO;
    }
    else if (item->HasVideoInfoTag())
    {
        id = item->GetVideoInfoTag()->m_iDbId;

        // TODO: Can be removed once this is properly handled when starting playback of a file
        if (id <= 0 && !item->GetPath().empty() &&
                (!item->HasProperty(LOOKUP_PROPERTY) || item->GetProperty(LOOKUP_PROPERTY).asBoolean()))
        {
            CVideoDatabase videodatabase;
            if (videodatabase.Open())
            {
                if (videodatabase.LoadVideoInfo(item->GetPath(), *item->GetVideoInfoTag()))
                    id = item->GetVideoInfoTag()->m_iDbId;

                videodatabase.Close();
            }
        }

        if (!item->GetVideoInfoTag()->m_type.empty())
            type = item->GetVideoInfoTag()->m_type;
        else
            CVideoDatabase::VideoContentTypeToString((VIDEODB_CONTENT_TYPE)item->GetVideoContentType(), type);

        if (id <= 0)
        {
            // TODO: Can be removed once this is properly handled when starting playback of a file
            item->SetProperty(LOOKUP_PROPERTY, false);

            object["item"]["title"] = item->GetVideoInfoTag()->m_strTitle;

            switch (item->GetVideoContentType())
            {
            case VIDEODB_CONTENT_MOVIES:
                if (item->GetVideoInfoTag()->m_iYear > 0)
                    object["item"]["year"] = item->GetVideoInfoTag()->m_iYear;
                break;
            case VIDEODB_CONTENT_EPISODES:
                if (item->GetVideoInfoTag()->m_iEpisode >= 0)
                    object["item"]["episode"] = item->GetVideoInfoTag()->m_iEpisode;
                if (item->GetVideoInfoTag()->m_iSeason >= 0)
                    object["item"]["season"] = item->GetVideoInfoTag()->m_iSeason;
                if (!item->GetVideoInfoTag()->m_strShowTitle.empty())
                    object["item"]["showtitle"] = item->GetVideoInfoTag()->m_strShowTitle;
                break;
            case VIDEODB_CONTENT_MUSICVIDEOS:
                if (!item->GetVideoInfoTag()->m_strAlbum.empty())
                    object["item"]["album"] = item->GetVideoInfoTag()->m_strAlbum;
                if (!item->GetVideoInfoTag()->m_artist.empty())
                    object["item"]["artist"] = StringUtils::Join(item->GetVideoInfoTag()->m_artist, " / ");
                break;
            }
        }
    }
    else if (item->HasMusicInfoTag())
    {
        id = item->GetMusicInfoTag()->GetDatabaseId();
        type = "song";

        // TODO: Can be removed once this is properly handled when starting playback of a file
        if (id <= 0 && !item->GetPath().empty() &&
                (!item->HasProperty(LOOKUP_PROPERTY) || item->GetProperty(LOOKUP_PROPERTY).asBoolean()))
        {
            CMusicDatabase musicdatabase;
            if (musicdatabase.Open())
            {
                CSong song;
                if (musicdatabase.GetSongByFileName(item->GetPath(), song, item->m_lStartOffset))
                {
                    item->GetMusicInfoTag()->SetSong(song);
                    id = item->GetMusicInfoTag()->GetDatabaseId();
                }

                musicdatabase.Close();
            }
        }

        if (id <= 0)
        {
            // TODO: Can be removed once this is properly handled when starting playback of a file
            item->SetProperty(LOOKUP_PROPERTY, false);

            CStdString title = item->GetMusicInfoTag()->GetTitle();
            if (title.IsEmpty())
                title = item->GetLabel();
            object["item"]["title"] = title;

            if (item->GetMusicInfoTag()->GetTrackNumber() > 0)
                object["item"]["track"] = item->GetMusicInfoTag()->GetTrackNumber();
            if (!item->GetMusicInfoTag()->GetAlbum().empty())
                object["item"]["album"] = item->GetMusicInfoTag()->GetAlbum();
            if (!item->GetMusicInfoTag()->GetArtist().empty())
                object["item"]["artist"] = item->GetMusicInfoTag()->GetArtist();
        }
    }
    else if (item->HasPictureInfoTag())
    {
        type = "picture";
        object["item"]["file"] = item->GetPath();
    }
    else
        type = "unknown";

    object["item"]["type"] = type;
    if (id > 0)
        object["item"]["id"] = id;

    Announce(flag, sender, message, object);
}
コード例 #8
0
void CAnnouncementManager::Announce(EAnnouncementFlag flag, const char *sender, const char *message, CFileItemPtr item, CVariant &data)
{
  if (!item.get())
  {
    Announce(flag, sender, message, data);
    return;
  }

  // Extract db id of item
  CVariant object = data.isNull() || data.isObject() ? data : CVariant::VariantTypeObject;
  CStdString type;
  int id = 0;

  if (item->HasVideoInfoTag())
  {
    id = item->GetVideoInfoTag()->m_iDbId;

    // TODO: Can be removed once this is properly handled when starting playback of a file
    if (id <= 0 && !item->GetPath().empty() &&
       (!item->HasProperty(LOOKUP_PROPERTY) || item->GetProperty(LOOKUP_PROPERTY).asBoolean()))
    {
      CVideoDatabase videodatabase;
      if (videodatabase.Open())
      {
        if (videodatabase.LoadVideoInfo(item->GetPath(), *item->GetVideoInfoTag()))
          id = item->GetVideoInfoTag()->m_iDbId;

        videodatabase.Close();
      }
    }

    CVideoDatabase::VideoContentTypeToString((VIDEODB_CONTENT_TYPE)item->GetVideoContentType(), type);

    if (id <= 0)
    {
      // TODO: Can be removed once this is properly handled when starting playback of a file
      item->SetProperty(LOOKUP_PROPERTY, false);

      object["title"] = item->GetVideoInfoTag()->m_strTitle;

      switch (item->GetVideoContentType())
      {
      case VIDEODB_CONTENT_MOVIES:
        if (item->GetVideoInfoTag()->m_iYear > 0)
          object["year"] = item->GetVideoInfoTag()->m_iYear;
        break;
      case VIDEODB_CONTENT_EPISODES:
        if (item->GetVideoInfoTag()->m_iEpisode >= 0)
          object["episode"] = item->GetVideoInfoTag()->m_iEpisode;
        if (item->GetVideoInfoTag()->m_iSeason >= 0)
          object["season"] = item->GetVideoInfoTag()->m_iSeason;
        if (!item->GetVideoInfoTag()->m_strShowTitle.empty())
          object["showtitle"] = item->GetVideoInfoTag()->m_strShowTitle;
        break;
      case VIDEODB_CONTENT_MUSICVIDEOS:
        if (!item->GetVideoInfoTag()->m_strAlbum.empty())
          object["album"] = item->GetVideoInfoTag()->m_strAlbum;
        if (!item->GetVideoInfoTag()->m_strArtist.empty())
          object["artist"] = item->GetVideoInfoTag()->m_strArtist;
        break;
      }
    }
  }
  else if (item->HasMusicInfoTag())
  {
    id = item->GetMusicInfoTag()->GetDatabaseId();
    type = "song";

    // TODO: Can be removed once this is properly handled when starting playback of a file
    if (id <= 0 && !item->GetPath().empty() &&
       (!item->HasProperty(LOOKUP_PROPERTY) || item->GetProperty(LOOKUP_PROPERTY).asBoolean()))
    {
      CMusicDatabase musicdatabase;
      if (musicdatabase.Open())
      {
        CSong song;
        if (musicdatabase.GetSongByFileName(item->GetPath(), song))
        {
          item->GetMusicInfoTag()->SetSong(song);
          item->SetMusicThumb();
          id = item->GetMusicInfoTag()->GetDatabaseId();
        }

        musicdatabase.Close();
      }
    }

    if (id <= 0)
    {
      // TODO: Can be removed once this is properly handled when starting playback of a file
      item->SetProperty(LOOKUP_PROPERTY, false);

      object["title"] = item->GetMusicInfoTag()->GetTitle();

      if (item->GetMusicInfoTag()->GetTrackNumber() > 0)
        object["track"] = item->GetMusicInfoTag()->GetTrackNumber();
      if (!item->GetMusicInfoTag()->GetAlbum().empty())
        object["album"] = item->GetMusicInfoTag()->GetAlbum();
      if (!item->GetMusicInfoTag()->GetArtist().empty())
        object["artist"] = item->GetMusicInfoTag()->GetArtist();
    }
  }
  else
    type = "unknown";

  object["item"]["type"] = type;
  if (id > 0)
    object["item"]["id"] = id;

  Announce(flag, sender, message, object);
}