Repository: xbmc/xbmc
File: xbmc/PlayListPlayer.cpp (C++)

Code before:
      if (list->Size() > 0)
      {
        Id playlistId = Id::TYPE_MUSIC;
        for (int i = 0; i < list->Size(); i++)
        {
          if (IsVideo(*list->Get(i)))
          {
            playlistId = Id::TYPE_VIDEO;
            break;
          }
        }

        ClearPlaylist(playlistId);
        SetCurrentPlaylist(playlistId);
        if (list->Size() == 1 && !IsPlayList(*list->Get(0)))
        {
          CFileItemPtr item = (*list)[0];
          // if the item is a plugin we need to resolve the URL to ensure the infotags are filled.
          if (URIUtils::HasPluginPath(*item) &&
              !XFILE::CPluginDirectory::GetResolvedPluginResult(*item))
          {
            return;
          }
          if (MUSIC::IsAudio(*item) || IsVideo(*item))
          {
            // Check if sources are locked - to capture media played via json-rpc
            if ((IsVideo(*item) && !g_passwordManager.IsVideoUnlocked()) ||
                (MUSIC::IsAudio(*item) && !g_passwordManager.IsMusicUnlocked()))
            {
              CLog::LogF(LOGERROR,
                         "MasterCode or MediaSource-code is wrong: {} will not be played.",
                         item->GetPath());
              return;
            }
            Play(item, pMsg->strParam);
          }
          else
            g_application.PlayMedia(*item, pMsg->strParam, playlistId);
        }
        else
        {
          // Handle "shuffled" option if present
          if (list->HasProperty("shuffled") && list->GetProperty("shuffled").isBoolean())
            SetShuffle(playlistId, list->GetProperty("shuffled").asBoolean(), false);
          // Handle "repeat" option if present
          if (list->HasProperty("repeat") && list->GetProperty("repeat").isInteger())
            SetRepeat(playlistId, static_cast<RepeatState>(list->GetProperty("repeat").asInteger()),
                      false);

          Add(playlistId, (*list));
          Play(pMsg->param1, pMsg->strParam);

Review comment (suggestion):
Not sure this method is the right place to handle json rpc as this class here is fairly generic and handles much more than json rpc. I would try to do this check somewhere in xbmc/interfaces/json-rpc

Code after:
      if (list->Size() > 0)
      {
        Id playlistId = Id::TYPE_MUSIC;
        for (int i = 0; i < list->Size(); i++)
        {
          if (IsVideo(*list->Get(i)))
          {
            playlistId = Id::TYPE_VIDEO;
            break;
          }
        }

        ClearPlaylist(playlistId);
        SetCurrentPlaylist(playlistId);
        if (list->Size() == 1 && !IsPlayList(*list->Get(0)))
        {
          CFileItemPtr item = (*list)[0];
          // if the item is a plugin we need to resolve the URL to ensure the infotags are filled.
          if (URIUtils::HasPluginPath(*item) &&
              !XFILE::CPluginDirectory::GetResolvedPluginResult(*item))
          {
            return;
          }
          const bool isVideo{VIDEO::IsVideo(*item)};
          const bool isAudio{MUSIC::IsAudio(*item)};
          if (isAudio || isVideo)
          {
            if ((isVideo && !g_passwordManager.IsVideoUnlocked()) ||
                (isAudio && !g_passwordManager.IsMusicUnlocked()))
            {
              CLog::LogF(LOGERROR,
                         "MasterCode or MediaSource-code is wrong: {} will not be played.",
                         item->GetPath());
              return;
            }
            Play(item, pMsg->strParam);
          }
          else
            g_application.PlayMedia(*item, pMsg->strParam, playlistId);
        }
        else
        {
          // Handle "shuffled" option if present
          if (list->HasProperty("shuffled") && list->GetProperty("shuffled").isBoolean())
            SetShuffle(playlistId, list->GetProperty("shuffled").asBoolean(), false);
          // Handle "repeat" option if present
          if (list->HasProperty("repeat") && list->GetProperty("repeat").isInteger())
            SetRepeat(playlistId, static_cast<RepeatState>(list->GetProperty("repeat").asInteger()),
                      false);

          Add(playlistId, (*list));