Reputation: 103
hey so I wanted to play a video as my konva stage. I used an example from sandbox but I cant figure out how to add the video player control to it.Can somebody help Thanks
constructor(...args) {
super(...args);
const video = document.createElement("video");
video.src = Vid;
video.type = "video/mp4";
video.controls = true; //I tried adding controls here
this.state = {
video: video,
timestamps: [],
};
video.addEventListener("canplay", () => {
video.play();
this.image.getLayer().batchDraw();
this.requestUpdate();
});
// video.addEventListener("keydown", () => {
//video.pause();
// });
//}
requestUpdate = () => {
this.image.getLayer().batchDraw();
requestAnimationFrame(this.requestUpdate);
};
render() {
return (
<Image
ref={(node) => {
this.image = node;
}}
height={window.innerHeight}
width={window.innerWidth}
image={this.state.video}
controls
/>
);
}
Upvotes: 0
Views: 473
Reputation: 20373
Such video on the canvas doesn't have regular controls, that you used to see on video inserted inside DOM.
When you draw video on the canvas, it works as an animated image. Nothing else.
If you want to have controls you can:
<video />
element somewhere in the DOM. You can place it on top of the canvas with absolute position.Upvotes: 0