public function playFile($file, $channels = 2)
    {
        $deferred = new Deferred();

        if (! file_exists($file)) {
            $deferred->reject(new FileNotFoundException("Could not find the file \"{$file}\"."));

            return $deferred->promise();
        }

        if (! $this->ready) {
            $deferred->reject(new \Exception('Voice Client is not ready.'));

            return $deferred->promise();
        }

        $process = $this->dcaEncode($file, $channels);
        $process->start($this->loop);

        return $this->playDCAStream($process);
    }
public function playFile($file, $channels = 2)
    {
        $deferred = new Deferred();

        if (! file_exists($file)) {
            $deferred->reject(new FileNotFoundException("Could not find the file \"{$file}\"."));

            return $deferred->promise();
        }

        if (! $this->ready) {
            $deferred->reject(new \Exception('Voice Client is not ready.'));

            return $deferred->promise();
        }

        $process = $this->dcaEncode($file, $channels);
        $process->start($this->loop);

        return $this->playDCAStream($process);
    }
public function playFile ( $ file , $ channels = 2 ) { $ deferred = new Deferred ( ) ; if ( ! file_exists ( $ file ) ) { $ deferred -> reject ( new FileNotFoundException ( "Could not find the file \"{$file}\"." ) ) ; return $ deferred -> promise ( ) ; } if ( ! $ this -> ready ) { $ deferred -> reject ( new \ Exception ( 'Voice Client is not ready.' ) ) ; return $ deferred -> promise ( ) ; } $ process = $ this -> dcaEncode ( $ file , $ channels ) ; $ process -> start ( $ this -> loop ) ; return $ this -> playDCAStream ( $ process ) ; }
Plays a file on the voice stream.

@param string $file     The file to play.
@param int    $channels How many audio channels to encode with.

@throws FileNotFoundException Thrown when the file specified could not be found.

@return \React\Promise\Promise
Plays a file on the voice stream .