Question

The title may be a little misleading, but I wanted to ask that how do I show only a part of video in my panel, for example I want to show only 17:00 to 18:00 in my program out of a 20:00 long video. Is there a way to do it? Because I found no such method or im just not able to think of a way to do it. Here's a piece of the working code: (here p1 is my panel, so is p2)

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        p = new Canvas();
        p.setSize(p1.getWidth(),p1.getHeight());
        o = new Canvas();
        p1.add(p);
        p2.add(o,BorderLayout.CENTER);
        m1 = new MediaPlayerFactory();
        m2 = new MediaPlayerFactory();
        e1 = m1.newEmbeddedMediaPlayer();
        e1.setVideoSurface(m1.newVideoSurface(p));
        e1.playMedia("E:\\My Folder\\Animes\\Naruto\\Naruto Shippuden\\Episodes\\Naruto Shippuden Episode 274\\[Narutoverse]_NARUTO_Shippuden_274_[720p].mkv");      // TODO add your handling code here:
    } 
Was it helpful?

Solution

Start playing at 30 seconds in:

mediaPlayer.playMedia(media, ":start-time=30");

Play from the beginning until 60 seconds in:

mediaPlayer.playMedia(media, ":stop-time=60");

Play between 30 and 60 seconds in:

mediaPlayer.playMedia(media, ":start-time=30", ":stop-time=60");

You can also specify e.g. "30.5" if you need to specify fractions of a second.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top