videojs / video.js

Video.js - open source HTML5 video player
https://videojs.com
Other
38.11k stars 7.45k forks source link

How to Restart / Replay video form start. #8017

Open Saqib92 opened 1 year ago

Saqib92 commented 1 year ago

Description

Is there a property to restart / replay video from start? I want to restart video and disabled play/pause button and Seekbar / controls so user can not pause / play video and change seek time.

I am using angular.

Reduced test case

No response

Steps to reproduce

this.player.currentTime(0);
this.player.controlBar.progressControl.disable();
this.player.controlBar.playToggle.disable();
this.player.play();

Errors

TypeError: null is not an object (evaluating 'this.children().forEach')
disable — video.es.js:14280
(anonymous function) — videoplayer.component.ts:39
timer — zone.js:3155
onInvokeTask — core.mjs:26510
(anonymous function) — zone.js:214
(anonymous function) — zone.js:525

What version of Video.js are you using?

^7.20.3

Video.js plugins used.

No response

What browser(s) including version(s) does this occur with?

Chrome, Edge, Firefox

What OS(es) and version(s) does this occur with?

Android, iOS, Mac,

welcome[bot] commented 1 year ago

👋 Thanks for opening your first issue here! 👋

If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can. To help make it easier for us to investigate your issue, please follow the contributing guidelines.

mister-ben commented 1 year ago

That ought to work. this.children()of a component would return an array of its child components. Have you done something else to modify the progressControl?

Saqib92 commented 1 year ago

As i said above i did this to restart video:

this.player.currentTime(0);  // current time to 0 ... But getting error here. 
this.player.controlBar.progressControl.disable();
this.player.controlBar.playToggle.disable();
this.player.play();
mister-ben commented 1 year ago

That's not enough to reproduce the issue, as that alone would not result in that error. Can you put together a minimal test case?

Saqib92 commented 1 year ago

Stackblitz link

Let video finish then click on restart.

video-archivist-bot commented 1 year ago

Hey! We've detected some video files in a comment on this issue. If you'd like to permanently archive these videos and tie them to this project, a maintainer of the project can reply to this issue with the following commands:

mister-ben commented 1 year ago

There's no such error on your stackblitz example. On Firefox there's a different error as it has no picture in picture, you might use this.player.controlBar.pictureInPictureToggle?.disable()