📄 media.java
字号:
package lib;
//import javax.microedition.media.*;
public class Media{// implements PlayerListener{
public static final int STATE_PLAYING=0;
public static final int STATE_PAUSE=1;
public static final int STATE_STOP=2;
public static final String TYPE_WAVE="audio/x-wav";
public static final String TYPE_AU="audio/basic";
public static final String TYPE_MP3="audio/mpeg";
public static final String TYPE_MIDI="audio/midi";
public static final String TYPE_Tone="audio/x-tone-seq";
// private int state;
// private Player player;
// private String name;
// private String type;
// private boolean loop;
// private static boolean isBusy;
public Media(String name,String type,boolean loop){
// this.name=name;
// this.type=type;
// this.loop=loop;
// state=STATE_STOP;
}
private void load(){
// try{
// player=Manager.createPlayer(this.getClass().getResourceAsStream(name),type);
// if(loop) player.setLoopCount(-1);
// player.addPlayerListener(this);
// }catch(Exception e){
// e.printStackTrace();
// }
}
private void release(){
// try{
// if(player!=null){
// player.stop();
// player.removePlayerListener(this);
// player.close();
// player=null;
// }
// }catch(Exception e){
// e.printStackTrace();
// }
}
//播放
public synchronized void play(){
// try{
// if(!isBusy && state==STATE_STOP){
// isBusy=true;
// load();
// state=STATE_PLAYING;
// player.prefetch();
// player.setMediaTime(0);
// player.start();
// }
// }catch(Exception e){
// e.printStackTrace();
// }
}
//暂停
public synchronized void pause(){
// try{
// if(state==STATE_PLAYING){
// player.stop();
// state=STATE_PAUSE;
// }
// }catch(Exception e){
// e.printStackTrace();
// }
}
//继续
public synchronized void resume(){
// try{
// if(state==STATE_PAUSE || (!isBusy && state==STATE_STOP && loop)){
// player.start();
// state=STATE_PLAYING;
// }
// }catch(Exception e){
// e.printStackTrace();
// }
}
//停止
public synchronized void stop(){
// try{
// if(state!=STATE_STOP){
// isBusy=false;
// release();
// state=STATE_STOP;
// }
// }catch(Exception e){
// e.printStackTrace();
// }
}
//获得状态
// public synchronized int getState(){
// return state;
// }
// public void playerUpdate(Player player, String event, Object eventData){
// if(event==PlayerListener.END_OF_MEDIA){
// if(!loop){
// isBusy=false;
// release();
// }
// }
// }
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -