import { Router } from "express";

function playerRouter({ queue }) {
  const router = Router();

  router.post("/play", async (req, res) => {
    await queue.start();
    res.json(queue.snapshot());
  });

  router.post("/pause", (req, res) => {
    queue.pause();
    res.json(queue.snapshot());
  });

  router.post("/resume", (req, res) => {
    queue.resume();
    res.json(queue.snapshot());
  });

  router.post("/skip", (req, res) => {
    queue.skip();
    res.json(queue.snapshot());
  });

  router.post("/stop", (req, res) => {
    queue.stop();
    res.json(queue.snapshot());
  });

  return router;
}

export { playerRouter };
