8

I am trying to create an Angular App which contains videos where the user needs to be logged out after a few minutes of inactivity.

  • If the user is watching the videos either normally or in fullscreen, he need not be logged out.

  • If the tab is inactive and the videos are playing I need him to be logged out after inactivity.

2
  • make use of a directive that check for mouse movements or clcik on the window and on setTimeout if nothing happens for that time frame log the user out Commented Oct 11, 2017 at 5:11
  • When viewing the video in fullscreen the cursor disappears, and then i go back to square one again. Commented Oct 11, 2017 at 16:15

1 Answer 1

7

The easiest way will be to use idlejs.

It works well with Angular and it includes .d.ts bindings for Typescript.

import { Idle } from 'idlejs/dist';

// with predefined events on `document`
const idle = new Idle()
  .whenNotInteractive()
  .within(60)
  .do(() => console.log('Logout user with a function'))
  .start();

When a user is playing a video you can stop the idle.

play(){
    this.idle.stop();
    // play movie
}

And when the user clicks pause / stop

pause(){
    this.idle.restart();
    // pause movie
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.