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

📄 playerdemo.java

📁 用J2ME开发的俄罗斯方块
💻 JAVA
字号:
package tetris;

import java.io.InputStream;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Display;
import javax.microedition.media.Control;
import javax.microedition.media.Manager;
import javax.microedition.media.MediaException;
import javax.microedition.media.Player;
import javax.microedition.media.PlayerListener;
import javax.microedition.media.TimeBase;

public class PlayerDemo implements Player{

	private Display display;
	private Player player;
//	private TetrisModel tetrisModel;

	public PlayerDemo() {
//		tetrisModel=t;
	}
	
	public void playbg(){
		InputStream is = getClass().getResourceAsStream("/bg.wav");
		try {
			player = Manager.createPlayer(is, "audio/x-wav");
			player.start();
		} catch (Exception e) {
			Alert alert = new Alert("错误!", "不能播放该文件!", null, AlertType.ALARM);
			alert.setTimeout(Alert.FOREVER);
			display.setCurrent(alert);
		}
//		if(tetrisModel.isGameOver()){
//			playgameover();
//		}else if(tetrisModel.handleFullRow()!=0){
//			playdispear();	
//		}
	}

	void playdispear() {
		InputStream is = getClass().getResourceAsStream("/dispear.wav");
		try {
			player = Manager.createPlayer(is, "audio/x-wav");
			player.start();
		} catch (Exception e) {
			Alert alert = new Alert("错误!", "不能播放该文件!", null, AlertType.ALARM);
			alert.setTimeout(Alert.FOREVER);
			display.setCurrent(alert);
		}
		
	}

	void playgameover() {
		InputStream is = getClass().getResourceAsStream("/gameover.wav");
		try {
			player = Manager.createPlayer(is, "audio/x-wav");
			player.start();
		} catch (Exception e) {
			Alert alert = new Alert("错误!", "不能播放该文件!", null, AlertType.ALARM);
			alert.setTimeout(Alert.FOREVER);
			display.setCurrent(alert);
		}
	}
	public void addPlayerListener(PlayerListener arg0) {
		if(Player.PREFETCHED!=0){
			try {
				player.start();
			} catch (MediaException e) {
				e.printStackTrace();
			}
		}		
	}

	public void close() {
		// TODO 自动生成方法存根
		
	}

	public void deallocate() {
		// TODO 自动生成方法存根
		
	}

	public String getContentType() {
		// TODO 自动生成方法存根
		return null;
	}

	public long getDuration() {
		// TODO 自动生成方法存根
		return 0;
	}

	public long getMediaTime() {
		// TODO 自动生成方法存根
		return 0;
	}

	public int getState() {
		// TODO 自动生成方法存根
		return 0;
	}

	public TimeBase getTimeBase() {
		// TODO 自动生成方法存根
		return null;
	}

	public void prefetch() throws MediaException {
		// TODO 自动生成方法存根
		
	}

	public void realize() throws MediaException {
		// TODO 自动生成方法存根
		
	}

	public void removePlayerListener(PlayerListener arg0) {
		// TODO 自动生成方法存根
		
	}

	public void setLoopCount(int arg0) {
		// TODO 自动生成方法存根
		
	}

	public long setMediaTime(long arg0) throws MediaException {
		// TODO 自动生成方法存根
		return 0;
	}

	public void setTimeBase(TimeBase arg0) throws MediaException {
		// TODO 自动生成方法存根
		
	}

	public void start() throws MediaException {
		// TODO 自动生成方法存根
		
	}

	public void stop() throws MediaException {
		// TODO 自动生成方法存根
		
	}

	public Control getControl(String arg0) {
		// TODO 自动生成方法存根
		return null;
	}

	public Control[] getControls() {
		// TODO 自动生成方法存根
		return null;
	}
	
}

⌨️ 快捷键说明

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