ajax.php
changeset 10 d3059e20b0fa
parent 6 5f35ebc4f9bb
child 18 69af47034212
equal deleted inserted replaced
9:63a257541313 10:d3059e20b0fa
    68       if ( !$allowcontrol )
    68       if ( !$allowcontrol )
    69         return false;
    69         return false;
    70       $tid =& $params[1];
    70       $tid =& $params[1];
    71       if ( !preg_match('/^[0-9]+$/', $tid) )
    71       if ( !preg_match('/^[0-9]+$/', $tid) )
    72       {
    72       {
    73         return die_json('Invalid track ID');
    73         return json_die('Invalid track ID');
    74       }
    74       }
    75       $tid = intval($tid);
    75       $tid = intval($tid);
    76       dcop_action('playlist', "playByIndex $tid");
    76       dcop_action('playlist', "playByIndex $tid");
    77       $return = array(
    77       $return = array(
    78         'current_track_length' => $playlist[$tid]['length_int'],
    78         'current_track_length' => $playlist[$tid]['length_int'],
    84       if ( !$allowcontrol )
    84       if ( !$allowcontrol )
    85         return false;
    85         return false;
    86       $volume =& $params[1];
    86       $volume =& $params[1];
    87       if ( !preg_match('/^[0-9]+$/', $volume) )
    87       if ( !preg_match('/^[0-9]+$/', $volume) )
    88       {
    88       {
    89         return die_json('Invalid track ID');
    89         return json_die('Invalid track ID');
    90       }
    90       }
    91       $volume = intval($volume);
    91       $volume = intval($volume);
    92       dcop_action('player', "setVolume $volume");
    92       dcop_action('player', "setVolume $volume");
    93       $return = array(
    93       $return = array(
    94         'volume' => $volume
    94         'volume' => $volume
    95         );
    95         );
    96       echo $json->encode($return);
    96       echo $json->encode($return);
       
    97       break;
       
    98     case 'seek':
       
    99       if ( !$allowcontrol )
       
   100         return false;
       
   101       $pos =& $params[1];
       
   102       if ( !preg_match('/^[0-9]+$/', $pos) )
       
   103       {
       
   104         return json_die('Invalid track ID');
       
   105       }
       
   106       $pos = intval($pos);
       
   107       dcop_action('player', "seek $pos");
       
   108       
    97       break;
   109       break;
    98     case 'refresh':
   110     case 'refresh':
    99       global $playlist_last_refresh, $playlist, $playlist_last_md5;
   111       global $playlist_last_refresh, $playlist, $playlist_last_md5;
   100       if ( $playlist_last_refresh + 60 < time() )
   112       if ( $playlist_last_refresh + 60 < time() )
   101       {
   113       {