<%pre>

#include <setup.h>
#include <recman.h>
#include <vdr/menu.h>

using namespace vdrlive;

</%pre>
<%args>
  std::string param;
</%args>
<%session scope="global">
  bool logged_in(false);
</%session>
<%cpp>
  if (!logged_in && LiveSetup().UseAuth()) {
    cToSvConcat targetUrl = "/login.html?redirect=";
    targetUrl.appendUrlEscaped(request.getQuery());
    return reply.redirect(targetUrl.data());
  }
  reply.setContentType( "application/xml" );

  const char *error_message = "";
  switch (RecordingsManager::CheckReplay(param)) {
    case 1: error_message = tr("Couldn't find recording or no recordings available."); break;
    case 2: error_message = tr("Not playing a recording."); break;
    case 3: error_message = tr("Not playing the same recording as from request."); break;
    default: break;
  }

  if (*error_message == 0) {
#if APIVERSNUM >= 20402
    cMutexLock mutexLock;
    cReplayControl* replayControl = reinterpret_cast<cReplayControl*>(cControl::Control(mutexLock));
#else
    cReplayControl* replayControl = reinterpret_cast<cReplayControl*>(cControl::Control());
#endif
    if (replayControl)
      replayControl->Backward();
    else
      error_message = tr("Cannot control playback!");
  }

</%cpp>
<& xmlresponse.ajax name=("rwd_recording") pname=("recording") value=(param) result=(*error_message == 0) error=(error_message) &>
