티스토리 뷰
반응형
#html
<video id="myPlayer" class="video-js vjs-default-skin" webkit-playsinline muted hidden></video>
#javascript
var player = videojs("myPlayer", {
sources: [{ src: "/resources/01.mp4", type: "video/mp4" }],
poster: "/resources/poster.png",
controls: false,
playsinline: false,
fluid: true, // fit
preload: "metadata",
});
//events
player.on("loadedmetadata", () => {
console.log("loadedmetadata");
});
player.on("loadeddata", () => {
console.log("loadeddata");
});
player.on("canplay", () => {
console.log("canplay");
});
player.on("canplaythrough", () => {
console.log("canplaythrough");
});
player.on("play", () => {
console.log("play");
});
player.on("seeked", () => {
console.log("seeked");
});
player.on("seeking", () => {
console.log("seeking");
});
player.on("ended", () => {
if (current == 0) {
player.play();
}
});
//play
const playVideo = (index, src, isAuto) => {
current = index;
player.src(src);
isAuto ? player.autoplay("true") : "";
player.load();
player.play();
};
#videojs
반응형
'자바스크립트(javascript)' 카테고리의 다른 글
[javascript/react] React.lazy / Suspense에 대하여 이해하기 (0) | 2022.10.04 |
---|---|
[javascript/react]리액트에서 list drag and drop (리스트 드래그 앤 드롭 구현) (0) | 2022.10.04 |
[javascript/html] chrome에서 full screen(전체화면) 체크하기 (0) | 2022.10.01 |
[css/javascript]@keyframes 애니메이션 연속으로 실행하기 (1) | 2022.09.30 |
[js/node/react] excel 파일 읽어서 정보 읽어들이기(Json 객체로 매핑) (0) | 2022.03.25 |
댓글
반응형