<?php

namespace App\Http\Controllers;

use App\Services\ObsWsClient;
use Illuminate\Http\Response;
use Throwable;

class MusicCommandController extends Controller
{
    public function send(string $type, ObsWsClient $ws): Response
    {
        try {
            $ws->broadcast('mpd:cmd', ['type' => $type]);
        } catch (Throwable $e) {
            return response($e->getMessage(), 502);
        }
        return response('', 204);
    }
}
