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

📄 mediainformationmenuelement.java

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

import javax.microedition.lcdui.Display;

import org.apache.log4j.Logger;

import no.auc.one.portableplayer.communication.mediaserver.*;
import no.auc.one.portableplayer.communication.mediarenderer.*;
import no.auc.one.portableplayer.librarymanager.*;
import no.auc.one.portableplayer.settings.Settings;

public class MediaInformationMenuElement extends MenuElement
{
    private static Logger LOG = Logger.getLogger("UI");
    private ContentDirectoryService cds = null;
    private MediaInformation media = null;
    private boolean playing = false;    
    
    public MediaInformationMenuElement(
        MediaInformation media,
        ContentDirectoryService cds) 
    {
        super(media.toString());
        
        if (cds == null) {
            throw new IllegalArgumentException("ContentDirectoryService can not be null");
        }

        this.cds = cds;

        if (media == null) {
            throw new IllegalArgumentException("Media can not be null");
        }

        this.media = media;
        
        System.out.println("New MediaInformationMenuElement. ResURI=" + media.getResourceUri());
    }

    public ContentDirectoryService getContentDirectoryService() {
        return cds;
    }

    public void setContentDirectoryService(ContentDirectoryService reqCds) {
        cds = reqCds;
    }

    public void invokeAction() {
        LOG.debug("menuAction for " + this);
        
        if (media instanceof TrackInformation) {
            try {
                Display d = Display.getDisplay(UI.getInstance().getOwner());
                InvokeMediaAction ima = new InvokeMediaAction(
                        !isPlaying() ? InvokeMediaAction.PLAYTRACK : InvokeMediaAction.PAUSE,
                        (TrackInformation)media);
                WaitingAlert wa = new WaitingAlert(
                    isPlaying() ? "Playing track: " + media : "Pause rendering",
                    d,
                    ima,
                    Thread.currentThread(),
                    false);                        
                d.setCurrent(wa, d.getCurrent());
                long start = System.currentTimeMillis();
                ima.start();
                ima.join();
                playing = !playing;
                if (System.currentTimeMillis() - start < 1000) {
                    wa.setTimeout(1000);
                } else {
                    wa.setTimeout(1);
                }                    
            } catch (InterruptedException ioe) {
                System.err.println("InterruptedException while playing content");
            }
        } else {
            LOG.debug("menuAction for " + this + "- unknown ");
            if (media != null) {
                LOG.debug("Media: " + media.getClass());
            } else {
                LOG.debug("Media == null");
            }
        }
    }
            
    public void naviateRight() {
        invokeAction();
    }
    
    public boolean isPlaying() {
        return playing;
    }
    
    public void setPlaying(boolean b) {
        playing = b;
    }    
}

⌨️ 快捷键说明

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