FileDocCategorySizeDatePackage
Example1.javaAPI DocJMF 2.1.1e3484Mon May 12 12:20:28 BST 2003None

Example1

public abstract class Example1 extends Object implements ControllerListener

Fields Summary
MediaLocator
mrl
Player
player
Component
controlComp
Component
visualComp
MenuComponent
zoomMenu
double
defaultScale
Panel
framePanel
Constructors Summary
Methods Summary
private voidaddPopupMenu(java.awt.Component comp)

    
public synchronized voidcontrollerUpdate(javax.media.ControllerEvent ce)

        if (ce instanceof FormatChangeEvent) {
            Dimension vSize = new Dimension(320,0);
            Component oldVisualComp = visualComp;
            
            if ((visualComp = player.getVisualComponent()) != null) {
                if (oldVisualComp != visualComp) {
                    if (oldVisualComp != null) {
                        oldVisualComp.remove(zoomMenu);
                    }
                    
                    framePanel.remove(oldVisualComp);
                    
                    vSize = visualComp.getPreferredSize();
                    vSize.width = (int) (vSize.width * defaultScale);
                    vSize.height = (int) (vSize.height * defaultScale);
                    
                    framePanel.add(visualComp);
                    
                    visualComp.setBounds(0, 0, vSize.width, vSize.height);
                    
                    addPopupMenu(visualComp);
                }
            }
            
            Component oldComp = controlComp;
            
            if ((controlComp = player.getControlPanelComponent()) != null) 
            {
                
                if (oldComp != controlComp)
                {
                    framePanel.remove(oldComp);
                    framePanel.add(controlComp);
                                         
                    if (controlComp != null) {
                        int prefHeight = controlComp.getPreferredSize().height;
                        
                        controlComp.setBounds(0, 
                                              vSize.height,
                                              vSize.width,
                                              prefHeight);
                    }
                }
            }
        }
    
private booleantest()


      
    
        // --- cut from here... --- //


        MediaLocator mrl= new MediaLocator("rtp://224.144.251.104:49150/audio/1");
        
        if (mrl == null) {
            System.err.println("Can't build MRL for RTP");
            return false;
        }
        
        // Create a player for this rtp session
        try {
            player = Manager.createPlayer(mrl);
        } catch (NoPlayerException e) {
            System.err.println("Error:" + e);
            return false;
        } catch (MalformedURLException e) {
            System.err.println("Error:" + e);
            return false;
        } catch (IOException e) {
            System.err.println("Error:" + e);
            return false;
        }
        
        if (player != null) {
            if (this.player == null) {
                this.player = player;
                player.addControllerListener(this);
                player.realize();
            }
        }

        // --- ...until here --- //

        return true;