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

📄 drmtestmidlet.java

📁 在SYMBIAN平台上用JAVA实现的DRM测试代码
💻 JAVA
字号:
/* This file was created by Carbide.j */

package drmtest;

import javax.microedition.io.Connector;
import javax.microedition.io.file.FileConnection;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.media.Manager;
import javax.microedition.media.Player;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

public class DrmTestMidlet extends MIDlet implements CommandListener {
  
  private final Command openBrowserCmd = new Command("Open Browser",Command.OK,0);
  private final Command openFileCmd = new Command("Open File",Command.OK,1);
  private final Command playFileCmd = new Command("Play file",Command.OK,2);
  private final Command exitCmd = new Command("Exit",Command.EXIT,1);
  private final String url = "http://200.152.210.97/waptest/homolog/homologacao/wallpaper/025_sax480.dm";
  private final String file = "file:///E:/Sounds/Digital/jack_aac_aac.dcf?drm=enc";
  private final String mediaFile = "file:///E:/Sounds/Digital/jack_aac_aac.dcf";
  private Form myForm = null;
  
  public DrmTestMidlet() {
    myForm = new Form("Download test");
    myForm.append("Choose a download option");
    myForm.addCommand(openBrowserCmd);
    myForm.addCommand(openFileCmd);
    myForm.addCommand(playFileCmd);
    myForm.addCommand(exitCmd);
  }
  
  protected void startApp(  ) throws MIDletStateChangeException {
    Display.getDisplay(this).setCurrent(myForm);
    myForm.setCommandListener(this);
  }
  
  protected void pauseApp(  ) {
  }
  
  protected void destroyApp( boolean p1 ) throws MIDletStateChangeException {
  }

  /* (non-Javadoc)
   * @see javax.microedition.lcdui.CommandListener#commandAction(javax.microedition.lcdui.Command, javax.microedition.lcdui.Displayable)
   */
  public void commandAction(Command arg0, Displayable arg1) {
    if(arg0 == openBrowserCmd) {
      try {
        System.out.println(System.getProperty("microedition.platform"));
        platformRequest(url);
      }
      catch(Exception e) {
        Alert error = new Alert("Error",e.toString(),null,AlertType.INFO);
        Display.getDisplay(this).setCurrent(error,myForm);
      }
    }
    else if(arg0 == exitCmd) {
      notifyDestroyed();
    }
    else if(arg0 == openFileCmd) {
      FileConnection fc = null;
      try {
        fc = (FileConnection)Connector.open(file,Connector.READ);
        if(fc != null && fc.exists()) {
          Alert error = new Alert("Success","File " + file + " opened",null,AlertType.INFO);
          Display.getDisplay(this).setCurrent(error,myForm);
        }
        else {
          throw new Exception("File not found");
        }
      }
      catch(Exception e) {
        Alert error = new Alert("Error",e.toString(),null,AlertType.INFO);
        Display.getDisplay(this).setCurrent(error,myForm);
      }
      finally {
        if(fc != null) {
          try {
            fc.close();
          }
          catch(Exception e) {}
        }
      }
    }
    else if(arg0 == playFileCmd) {
      Player p = null;
      try {
        p = Manager.createPlayer(mediaFile);
        p.start();
      }
      catch(Exception e) {
        Alert error = new Alert("Error",e.toString(),null,AlertType.INFO);
        Display.getDisplay(this).setCurrent(error,myForm);
      }
      finally {
        if(p != null) {
          try {
            p.close();
          }
          catch(Exception e) {}
        }
      }
    }
  }

  
  
}

⌨️ 快捷键说明

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