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

📄 songthread.java

📁 用java写的浏览器的服务器和客户端程序
💻 JAVA
字号:
/**
 * Email: taorundong@126.com
 *
 * @author taorundong
 * @version 1.00 07/02/14
 */
 
//create a song thread use the package of JMF
import javax.media.*;
import java.net.*;


public class SongThread extends Thread implements Runnable{
	
	private
	URL urlSong = null;
	Player player = null;
	String nameSong = null;
	
	SongThread(String temp){
		
		super();
		nameSong = temp;
		init();
		
	}
	
	
	public void init(){
		
		try{
			urlSong = this.getClass().getResource(nameSong);
		//	System.out.println(urlSong);
			player = Manager.createPlayer(urlSong);
			player.prefetch();
		}
		catch(Exception e){
			e.printStackTrace();
		}
			
	}
	
	
	public void startPlay(){
		
		try{
			player.start();
		}
		catch(Exception e){
			e.printStackTrace();
		}
		
	}
	
	
	public void run(){
		
	//	init();
		startPlay();
		
	}
	
	
	public void setNameSong(String temp){
		nameSong = temp;
	}
	
	
	public String getNameSong(){
		return nameSong;
	}
	
	
	public static void main(String args[]){
		SongThread thread = new SongThread("music\\press.wav");
		thread.run();
	}
	
	
}
//maybe multithread construction can improve the performence of your program,but with only one 
//cpu,the improvement is so limited!

⌨️ 快捷键说明

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