videogular2 icon indicating copy to clipboard operation
videogular2 copied to clipboard

Which event do i need to capture when the video is cancelled without being ended

Open akamanzi opened this issue 6 years ago • 8 comments

Hi, First thumbs up to the work put on this great library.

I am having trouble which event to capture when the video is canceled without ending. I want to implement a resume video feature. and i need to capture the event when a user decides to cancel the video without the video being ended.

Any pointers would be really helpful.

Thanks in advance

akamanzi avatar Nov 29 '18 15:11 akamanzi

@akamanzi how can a user "cancel" a video?

Elecash avatar Nov 30 '18 08:11 Elecash

@Elecash, what i meant is when a user presses the browser back button when the video is not yet ended

akamanzi avatar Dec 03 '18 07:12 akamanzi

@akamanzi In my opinion, that's not Videogulars's job to provide these events, but you can handle this by angular itself.

First of all, you need to decide what kind of event you want to handle. a) Close/refresh tab or browser b) Naviagtion changed

a) Listen to the host event window:beforeunload @HostListener('window:beforeunload', ['$event']) saveVideoPlayback($event: any) { this.videoResumeService.pushVideo(videoId, position); } b) You need to implement your own CanDeactivate-Guard see Angular-Documentation

ViktorReib avatar Dec 03 '18 08:12 ViktorReib

@ViktorReib Thanks for the help and pointers. Let me definitely try to implement this.

akamanzi avatar Dec 05 '18 07:12 akamanzi

@Elecash, @ViktorReib I am trying to setup the currentTime manually using the API, in firefox it is working fine but with Chrome it is not. What am i doing wrong? Below is the code snippet this.api.getDefaultMedia().currentTime = 120;

Thanks in advance

akamanzi avatar Dec 05 '18 08:12 akamanzi

Did you read the manual page using-the-api? This works for me:

  onPlayerReady(api:VgAPI) {
    this.api = api;
    this.api.getDefaultMedia().currentTime = 5;
  }

Chrome 70.0.3538.110 Firefox 63.0.3

ViktorReib avatar Dec 05 '18 09:12 ViktorReib

@ViktorReib, I am using the exact same code but for some reasons in is not working in chrome. With firefox it is working fine but with chrome it is not. Below is the code snippet

onPlayerReady(api: VgAPI, fullscreen: VgFullscreenAPI) {
    this.api = api;
this.api.getDefaultMedia().subscriptions.loadedMetadata.subscribe(
      () => {
        this.data.checkBalance().subscribe(response => {
          console.log("response", response)
          if (response['success']){
              if (this.api.getDefaultMedia().canPlayThrough){
                this.api.getDefaultMedia().currentTime = 120;
              }
}
        })
      }
    );
}

Chrome 70.0.3538.110 Firefox 63.0.3

akamanzi avatar Dec 05 '18 12:12 akamanzi

Could you please provide an stackblitz example? I think the mistake will have been hidden in the details :)

ViktorReib avatar Dec 12 '18 16:12 ViktorReib