0 Replies Latest reply: Feb 29, 2012 3:24 PM by 910151 RSS

    Green screen before mpg execution

    910151
      Hello,

      I'm trying to play an mpg video in loop with the following code:
      public class JMPanel extends JPanel implements ControllerListener {
      
           public JMPanel() {
                super(true);
                this.setBackground(Color.black);
           }
      
           public void initPlayer(String url) {
                setLayout(new BorderLayout());
                try {
                     URL mediaURL = new URL(url);
                     if(mplayer!=null)mplayer.close();
                     mplayer = Manager.createPlayer(mediaURL);
                     mplayer.addControllerListener(this);
                }
                catch (Exception e) {
                     ...
                }
           }
      
           public void start(String path, boolean loop) throws InterruptedException {
                this.loop = loop;
                this.removeAll();
                this.initPlayer(path);
                mplayer.start();
           }
      
           public void controllerUpdate(ControllerEvent event) {
                if(event instanceof StopEvent){
                     //System.out.println("stopp");
                     if(loop){
                          mplayer.setMediaTime(new Time(0));
                          mplayer.start();
                     }
                }
           }
      }
      Before the first execution there is a green screen (around 1 second), however the following loops work fine.
      How can avoid this green screen?
      Thanks in advance!
      Paolo