0

How to code in Java (with Java Media Framework): When the player reaches a certain time playing a video clip (for example, reaching 3.124 minutes in reproduction time), it generates an event?

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by emilo35
0

Hello! Here is an example of how you could implement a timer that will generate events every interval of delay millisecs. If you wand an event generated after 3.124 minutes, you could either initialize your timer with delay delay = 187440 (and then use t.stop(); when you received your event.

You could otherwise initialize your delay to like 1000 (one event every second, and then use a counter to count how many seconds have passed).

public class TimerExample implements ActionListener {

    javax.swing.Timer t = null;

    public TimerExample(int delay) {
        //Delay between timer events in milliseconds
        t = new javax.swing.Timer(delay, this); 
        t.start();
    }

    public void actionPerformed(ActionEvent e) {
        // Do stuff
    }
}

Good luck!

Regards,
Emil Olofsson

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.