Repository: xbmc/xbmc
File: xbmc/application/Application.cpp (C++)

Code before:
  }

  if (PLAYLIST::IsPlayList(item))
    return false;

  // Translate/Resolve the url if needed - recursively, but only limited times.
  static constexpr size_t MAX_ITEM_RESOLVE_ATTEMPTS{5};

  std::string lastDynPath{item.GetDynPath()};
  size_t itemResolveAttempt{0};
  while (itemResolveAttempt < MAX_ITEM_RESOLVE_ATTEMPTS)
  {
    itemResolveAttempt++;

    const std::unique_ptr<IDirectory> dir{CDirectoryFactory::Create(item)};
    if (dir && !dir->Resolve(item))
    {
      CLog::LogF(LOGERROR, "Error resolving item. Item '{}‘ is not playable.", item.GetDynPath());
      return false;
    }

    const std::string newDynPath{item.GetDynPath()};
    if (newDynPath == lastDynPath)
      break; // done

    lastDynPath = newDynPath;
  }

  // if we have a stacked set of files, we need to setup our stack routines for
  // "seamless" seeking and total time of the movie etc.
  // will recall with restart set to true
  if (item.IsStack())
    return PlayStack(item, bRestart);

  CPlayerOptions options;

  if (item.HasProperty("StartPercent"))
  {
    options.startpercent = item.GetProperty("StartPercent").asDouble();
    item.SetStartOffset(0);
  }

  options.starttime = CUtil::ConvertMilliSecsToSecs(item.GetStartOffset());

  if (bRestart)
  {
    // have to be set here due to playstack using this for starting the file
    if (item.HasVideoInfoTag())
      options.state = item.GetVideoInfoTag()->GetResumePoint().playerState;
  }
  if (!bRestart || stackHelper->IsPlayingISOStack())

Review comment (suggestion):
Depending on how you feel about saving a copy:
```suggestion
    std::string newDynPath{item.GetDynPath()};
    if (newDynPath == lastDynPath)
      break; // done

    lastDynPath = std::move(newDynPath);
```

Code after:
  }

  if (PLAYLIST::IsPlayList(item))
    return false;

  // Translate/Resolve the url if needed - recursively, but only limited times.
  std::string lastDynPath{item.GetDynPath()};
  size_t itemResolveAttempt{0};
  while (itemResolveAttempt < MAX_ITEM_RESOLVE_ATTEMPTS)
  {
    itemResolveAttempt++;

    const std::unique_ptr<IDirectory> dir{CDirectoryFactory::Create(item)};
    if (dir && !dir->Resolve(item))
    {
      CLog::LogF(LOGERROR, "Error resolving item. Item '{}‘ is not playable.", item.GetDynPath());
      return false;
    }

    std::string newDynPath{item.GetDynPath()};
    if (newDynPath == lastDynPath)
      break; // done

    lastDynPath = std::move(newDynPath);
  }

  // if we have a stacked set of files, we need to setup our stack routines for
  // "seamless" seeking and total time of the movie etc.
  // will recall with restart set to true
  if (item.IsStack())
    return PlayStack(item, bRestart);

  CPlayerOptions options;

  if (item.HasProperty("StartPercent"))
  {
    options.startpercent = item.GetProperty("StartPercent").asDouble();
    item.SetStartOffset(0);
  }

  options.starttime = CUtil::ConvertMilliSecsToSecs(item.GetStartOffset());

  if (bRestart)
  {
    // have to be set here due to playstack using this for starting the file
    if (item.HasVideoInfoTag())
      options.state = item.GetVideoInfoTag()->GetResumePoint().playerState;
  }
  if (!bRestart || stackHelper->IsPlayingISOStack())
  {
    // the following code block is only applicable when bRestart is false OR to ISO stacks