/*ch0914.java*/
import javax.media.*;
import java.awt.*;
import java.applet.*;
import java.io.*;
import java.net.*;
public class ch0914 extends Applet implements ControllerListener
{ URL url;
  Player ply=null;
  Component vcmp=null;
  Component ccmp=null;
  
  public void init()
  { setBackground(Color.cyan);
    try
    { url=new URL(getDocumentBase(),"ÓîÖæÅÆÏãÑÌ.mp3");
      ply=Manager.createPlayer(url);
      if(ply!=null)
        ply.addControllerListener(this);
      else
        System.out.println("failed to Create player");
    }
    catch(Exception e)
    {
    }
  }
  public void start()
  { if(ply!=null)
    { ply.realize();
      ply.prefetch();
    }
  }

  public synchronized void controllerUpdate(ControllerEvent e)
  { if(e instanceof RealizeCompleteEvent)
    { if((vcmp=ply.getVisualComponent())!=null)
        add(vcmp,"");
      if((ccmp=ply.getControlPanelComponent())!=null)
        add(ccmp,"");
      validate();
    }
    else if(e instanceof PrefetchCompleteEvent)
      ply.start();
  }
  
  public void stop()
  { if(ply!=null)
    { ply.stop();
      ply.deallocate();
    }
  }
}
