| import axios from "axios"; | |
| import React from "react"; | |
| import { useSelector } from "react-redux"; | |
| import styled from "styled-components"; | |
| export default function Volume() { | |
| const { token } = useSelector((state) => state.user); | |
| const setVolume = async (e) => { | |
| try { | |
| await axios.put( | |
| "https://api.spotify.com/v1/me/player/volume", | |
| {}, | |
| { | |
| params: { | |
| volume_percent: parseInt(e.target.value), | |
| }, | |
| headers: { | |
| "Content-Type": "application/json", | |
| Authorization: "Bearer " + token, | |
| }, | |
| } | |
| ); | |
| } catch (error) {} | |
| }; | |
| return ( | |
| <Container> | |
| <input type="range" onMouseUp={(e) => setVolume(e)} min={0} max={100} /> | |
| </Container> | |
| ); | |
| } | |
| const Container = styled.div` | |
| display: flex; | |
| justify-content: flex-end; | |
| align-content: center; | |
| input { | |
| width: 15rem; | |
| border-radius: 2rem; | |
| height: 0.5rem; | |
| } | |
| `; | |