How to run a function on a component before user leaves the page

Hi, I have a page called syllabusPage and that page is calling various components, one being a video component being just an iframe and some ts code to load, play, and pause vimeo videos.

so when a user tries to leave syllabus page i want the videoComponent to pick up the users place in the video and save it - that part i can do with my getTime() function.

But im not sure how to call the getTime function, i tried using ngOnDestroy and ionViewWillLeave. ngOnDestroy calls the function but i think shortly after its called the process is terminated - all i get is the first console.log.

console.log('getting time')
    this.player1.getCurrentTime().then(function(seconds) {
  }).catch(function(error) {
      // an error occurred

And ionViewWillLeave doesnt work at all.
Any help would be appreciated!