⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 .#main.java.1.8.2.5

📁 国外的j2me播放器软件
💻 5
字号:
package no.auc.one.portableplayer;

import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

import no.auc.one.portableplayer.communication.UPnPPresenceAdvertisementHandling;
import no.auc.one.portableplayer.communication.upnphosting.UPnPHosting;
import no.auc.one.portableplayer.lmr.MediaRenderer;
import no.auc.one.portableplayer.lms.ServerDevice;
import no.auc.one.portableplayer.userinterface.UI;

import org.apache.log4j.LogActivator;
import org.apache.log4j.Logger;

import ch.ethz.jadabs.osgi.j2me.OSGiContainer;

/**
 * Main is the startup class and responsible for starting the user interface 
 * subsystem which controls the rest of the application.
 *
 */
public class Main extends MIDlet {
	
    public static Logger LOG;
    private UPnPPresenceAdvertisementHandling pah;
    private boolean isPaused = false;

    public Main() {
        // create OSGi container and set container 
        // properties from the MIDP application properties
        OSGiContainer osgicontainer = OSGiContainer.Instance();
        osgicontainer.setProperty(
            "log4j.priority", 
            getAppProperty("log4j.priority"));
        osgicontainer.startBundle(new LogActivator());
   
        // obtain a Logger from the logger factory for this class
        LOG = Logger.getLogger("Main");
    }

    /**
     * Pass control over to the user interface subsystem.
     */
	protected void startApp() throws MIDletStateChangeException {
        if (!isPaused) {
            try {
                Logger.getLogCanvas().setDisplay(
                    javax.microedition.lcdui.Display.getDisplay(this));
            
                UI ui = UI.getInstance();
                ui.setOwner(this);
                ui.show();

                /* PAH commented out due to lack of multicast support in J2ME :/
                // Start UPnP Presence Advertisement Handling thread
                pah = new UPnPPresenceAdvertisementHandling();
                pah.registerHandler(
                    new no.auc.one.portableplayer.communication.mediarenderer.MediaRendererPAH());
                pah.setPriority(Thread.MIN_PRIORITY);
                pah.start();
                */

                UPnPHosting hosting = UPnPHosting.getInstance();
                hosting.start();
                
                LOG.debug("Registering LMS");
                hosting.registerDevice(ServerDevice.getInstance());
                LOG.debug("LMS registered");
                
                LOG.debug("Registering LMR");
                hosting.registerDevice(MediaRenderer.getInstance());
            } catch (Exception e) {
                LOG.fatal("Main unhandled Exception occured...");
                LOG.fatal(e);
            }
        } else {
            isPaused = false;
            pah.start();
        }
	}

    /**
     * Called by the Application Management Software (AMS) when the 
     * application should enter 'Pause mode', and shut down as much of its 
     * activity as possible.
     *
     * Currently this method does nothing.
     */
	protected void pauseApp() {
        // Pause the PAH thread
        // pah. 

        isPaused = true;
	}

    /**
     * Called by the Application Management Software (AMS) when the 
     * application is destroyed.
     */
	protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
	}
	
    /**
     * Terminates the application.
     */
	public void quit() {
		try {
			destroyApp(true);
			notifyDestroyed();
		} catch (MIDletStateChangeException e) {
			e.printStackTrace();
		}
	}	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -