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?

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.