我尝试在 reactjs 中制作视频播放器
这是我的代码
import "./App.css";
import React, { Component, useState } from "react";
import ReactPlayer from "react-player";\
function App() {
const [myvideo, setMyvideo] = useState("");
const arrayqueue = [
{
singer: "The Valley",
videoname: "video/video_test.mp4",
},
{
singer: "My Friend",
videoname: "video/video_test2.mp4",
},
{
singer: "Say wow",
videoname: "video/video_test3.mp4",
},
];
return (
<div>
<ReactPlayer url={myvideo} controls={true} />
<div className="queue-size" id="style-1">
{arrayqueue.map((item, index) => {
return (
<div
className="row-queue"
key={index}
onClick={() => setMyvideo(item.videoname)}
>
<div className="column-queue">{item.singer}</div>
</div>
);
})}
</div>
</div>
);
}
export default App;
我成功在队列中进行 onclick 并将视频设置为 ReactPlayer,我的问题是如何让 ReactPlayer 自动播放队列中的下一个,所以 ReactPlayer 有 2 个选项,如果我不点击队列,视频将从排队,谢谢:)