Skip to content

Commit

Permalink
feat(client): added download feature : You can now download the curre…
Browse files Browse the repository at this point in the history
…nt video on your device
  • Loading branch information
Will Moss committed Jul 18, 2024
1 parent 0a384d0 commit a2fde4c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
16 changes: 16 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,22 @@ const App = () => {
const [muted, setMuted] = useState(true);
const toggleMute = () => setMuted(!muted);

// Video control - Download the current video
const download = () => {
const url = videos[0].url;

const anchor = document.createElement("a");
anchor.href = url;
anchor.download = url.split("/").pop();
anchor.target = "_blank";

document.body.appendChild(anchor);

anchor.click();

document.body.removeChild(anchor);
};

// Member - Saves a ref to every video element on the page
const videoRefs = useRef([]);
const saveVideoRef = (index) => (ref) => {
Expand Down
16 changes: 8 additions & 8 deletions src/components/BottomNavbar/index.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Assets
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faVolumeMute, faVolumeUp } from '@fortawesome/free-solid-svg-icons';
import './index.css';
import { faDownload, faVolumeMute, faVolumeUp } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import "./index.css";

const BottomNavbar = ({ isMuted, onToggleMute }) => {
const BottomNavbar = ({ isMuted, onToggleMute, onDownload }) => {
return (
<div className="bottom-navbar">
<button type="button" className="nav-item" onClick={onDownload}>
<FontAwesomeIcon icon={faDownload} className="icon" />
</button>
<button type="button" className="nav-item" onClick={onToggleMute}>
<FontAwesomeIcon
icon={!isMuted ? faVolumeUp : faVolumeMute}
className="icon"
/>
<FontAwesomeIcon icon={!isMuted ? faVolumeUp : faVolumeMute} className="icon" />
</button>
</div>
);
Expand Down

0 comments on commit a2fde4c

Please sign in to comment.