controllers/DownloadController.php
private function getAudioResponse(Request $request, Response $response)
    {
        try {
            // First, we try to get a MP3 file directly.
            if (!empty($request->getQueryParam('from')) || !empty($request->getQueryParam('to'))) {
                throw new Exception('Force convert when we need to seek.');
            }

            if ($this->config->stream) {
                $this->video = $this->video->withFormat('mp3');

                return $this->getStream($request, $response);
            } else {
                $this->video = $this->video->withFormat('mp3[protocol=https]/mp3[protocol=http]');

                $urls = $this->video->getUrl();

                return $response->withRedirect($urls[0]);
            }
        } catch (PasswordException $e) {
            $frontController = new FrontController($this->container);

            return $frontController->password($request, $response);
        } catch (Exception $e) {
            // If MP3 is not available, we convert it.
            $this->video = $this->video->withFormat($this->defaultFormat);

            return $this->getConvertedAudioResponse($request, $response);
        }
    }
private function getAudioResponse(Request $request, Response $response)
    {
        try {
            // First, we try to get a MP3 file directly.
            if (!empty($request->getQueryParam('from')) || !empty($request->getQueryParam('to'))) {
                throw new Exception('Force convert when we need to seek.');
            }

            if ($this->config->stream) {
                $this->video = $this->video->withFormat('mp3');

                return $this->getStream($request, $response);
            } else {
                $this->video = $this->video->withFormat('mp3[protocol=https]/mp3[protocol=http]');

                $urls = $this->video->getUrl();

                return $response->withRedirect($urls[0]);
            }
        } catch (PasswordException $e) {
            $frontController = new FrontController($this->container);

            return $frontController->password($request, $response);
        } catch (Exception $e) {
            // If MP3 is not available, we convert it.
            $this->video = $this->video->withFormat($this->defaultFormat);

            return $this->getConvertedAudioResponse($request, $response);
        }
    }
private function getAudioResponse ( Request $ request , Response $ response ) { try { // First, we try to get a MP3 file directly. if ( ! empty ( $ request -> getQueryParam ( 'from' ) ) || ! empty ( $ request -> getQueryParam ( 'to' ) ) ) { throw new Exception ( 'Force convert when we need to seek.' ) ; } if ( $ this -> config -> stream ) { $ this -> video = $ this -> video -> withFormat ( 'mp3' ) ; return $ this -> getStream ( $ request , $ response ) ; } else { $ this -> video = $ this -> video -> withFormat ( 'mp3[protocol=https]/mp3[protocol=http]' ) ; $ urls = $ this -> video -> getUrl ( ) ; return $ response -> withRedirect ( $ urls [ 0 ] ) ; } } catch ( PasswordException $ e ) { $ frontController = new FrontController ( $ this -> container ) ; return $ frontController -> password ( $ request , $ response ) ; } catch ( Exception $ e ) { // If MP3 is not available, we convert it. $ this -> video = $ this -> video -> withFormat ( $ this -> defaultFormat ) ; return $ this -> getConvertedAudioResponse ( $ request , $ response ) ; } }
Return the MP3 file.

@param Request  $request  PSR-7 request
@param Response $response PSR-7 response

@return Response HTTP response
Return the MP3 file .