Skip to content

Commit

Permalink
Autoplay video
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincharles committed Feb 8, 2023
1 parent 78b25e0 commit 1cf9ed6
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/Tools/_framework/ToolPanels/HomePanel.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useRef } from 'react';
import React, { useEffect, useRef } from 'react';
import { useNavigate } from 'react-router-dom'
import Cookies from 'js-cookie'; // import Textinput from "../imports/Textinput";
import styled from 'styled-components';
Expand Down Expand Up @@ -112,6 +112,20 @@ export default function HomePage(props) {
const [signedIn, setSignedIn] = useState(null);
let checkingCookie = useRef(false);

const videoEl = useRef(null);

const attemptPlay = () => {
videoEl &&
videoEl.current &&
videoEl.current.play().catch(error => {
console.error("Error attempting to play", error);
});
};

useEffect(() => {
attemptPlay();
}, []);

//Only ask once
if (!checkingCookie.current) {
checkingCookie.current = true;
Expand Down Expand Up @@ -178,9 +192,12 @@ export default function HomePage(props) {
src='/media/homepagevideo.mp4'
loop
muted
autoplay
controls
/>
playsInline
alt="Demonstration video on making DoenetML content"
ref={videoEl}
// autoplay
// controls
><source src="/media/homepagevideo.mp4" type="video/mp4" /></video>

</div>

Expand Down

0 comments on commit 1cf9ed6

Please sign in to comment.