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

📄 mulplayer.java.bak

📁 手机2种声音类型同时播放测试JAVA程序
💻 BAK
📖 第 1 页 / 共 2 页
字号:
       	    th1.start();         	           	    		} else if ((testChoiceGroup.isSelected(0) == true)&&(testChoiceGroup.isSelected(1) == false)		   &&(testChoiceGroup.isSelected(2) == true)&&(testChoiceGroup.isSelected(3) == false)		   &&(testChoiceGroup.isSelected(4) == false)) {			reply();			
			Thread th0 = new MidThread("mid");			Thread th2 = new MidThread("amr");       	    th0.start();        	    th2.start();  	       	           	    		} else if ((testChoiceGroup.isSelected(0) == true)&&(testChoiceGroup.isSelected(1) == false)		   &&(testChoiceGroup.isSelected(2) == false)&&(testChoiceGroup.isSelected(3) == true)		   &&(testChoiceGroup.isSelected(4) == false)) {			reply();			
			Thread th0 = new MidThread("mid");       	    Thread th3 = new MidThread("wav");       	    th0.start();  			       	    th3.start();         	          	    		} else if ((testChoiceGroup.isSelected(0) == true)&&(testChoiceGroup.isSelected(1) == false)		   &&(testChoiceGroup.isSelected(2) == false)&&(testChoiceGroup.isSelected(3) == false)		   &&(testChoiceGroup.isSelected(4) == true)) {			reply();			
			Thread th0 = new MidThread("mid");			Thread th4 = new MidThread("dat");       	    th0.start();         	    th4.start();  					} else if ((testChoiceGroup.isSelected(0) == false)&&(testChoiceGroup.isSelected(1) == true)		   &&(testChoiceGroup.isSelected(2) == true)&&(testChoiceGroup.isSelected(3) == false)		   &&(testChoiceGroup.isSelected(4) == false)) {			reply();			
			Thread th1 = new MidThread("mmf");			Thread th2 = new MidThread("amr");       	    th1.start();       	    th2.start(); 		} else if ((testChoiceGroup.isSelected(0) == false)&&(testChoiceGroup.isSelected(1) == true)		   &&(testChoiceGroup.isSelected(2) == false)&&(testChoiceGroup.isSelected(3) == true)		   &&(testChoiceGroup.isSelected(4) == false)) {			reply();			
			Thread th1 = new MidThread("mmf");    	    
			Thread th3 = new MidThread("wav");       	    th1.start();   			       	    th3.start();        	    		} else if ((testChoiceGroup.isSelected(0) == false)&&(testChoiceGroup.isSelected(1) == true)		   &&(testChoiceGroup.isSelected(2) == false)&&(testChoiceGroup.isSelected(3) == false)		   &&(testChoiceGroup.isSelected(4) == true)) {			reply();			
			Thread th1 = new MidThread("mmf");    	    
			Thread th4 = new MidThread("dat");       	    th1.start();   			       	    th4.start();    		} else if ((testChoiceGroup.isSelected(0) == false)&&(testChoiceGroup.isSelected(1) == false)		   &&(testChoiceGroup.isSelected(2) == true)&&(testChoiceGroup.isSelected(3) == true)		   &&(testChoiceGroup.isSelected(4) == false)) {			reply();			
			Thread th2 = new MidThread("amr");  				Thread th3 = new MidThread("wav");       	    th2.start();			       	    th3.start();       	           	           	           	           	          	           	           	           	    			       	    		} else if ((testChoiceGroup.isSelected(0) == false)&&(testChoiceGroup.isSelected(1) == false)		   &&(testChoiceGroup.isSelected(2) == true)&&(testChoiceGroup.isSelected(3) == false)		   &&(testChoiceGroup.isSelected(4) == true)) {			reply();			
			Thread th2 = new MidThread("amr");  				Thread th4 = new MidThread("dat");       	    th2.start();	       	    th4.start();  		       	    		} else if ((testChoiceGroup.isSelected(0) == false)&&(testChoiceGroup.isSelected(1) == false)		   &&(testChoiceGroup.isSelected(2) == false)&&(testChoiceGroup.isSelected(3) == true)		   &&(testChoiceGroup.isSelected(4) == true)) { 				reply();			
			Thread th3 = new MidThread("wav");			Thread th4 = new MidThread("dat");       	    th3.start();        	    th4.start();  		
		}  else {
			System.out.println("Please choice midea more than two ");
		}       	 
//退出功能       	             } else if (c == exitCommand) {			testChoiceGroup.setSelectedIndex(0,false);		       		testChoiceGroup.setSelectedIndex(1,false);		       		testChoiceGroup.setSelectedIndex(2,false);		       		testChoiceGroup.setSelectedIndex(3,false);		       		testChoiceGroup.setSelectedIndex(4,false);					System.out.println("-------------exitCommand-------");    				        	        		if (is != null) {        			is.close();					System.out.println("-------------is.close-------");                			is = null;        		}	          		if (is2 != null) {        			is2.close();					System.out.println("-------------is2.close-------");                			is2 = null;        		          				        	    }        		if (p != null) {        			p.stop();					System.out.println("-------------p.stop-------");                			p = null;        		}	            	        		if (p2 != null) {        			p2.stop();					System.out.println("-------------p2.stop-------");                			p2 = null;        		}	        		        		                destroyApp(true);            }        } catch (Exception ex) {            ex.printStackTrace();        }
	}

	private void reply() {
	try{
		if (is != null) {        	is.close(); 			is = null;        }	          if (is2 != null) {        	is2.close();			is2 = null;        		          				   	    }
   	    if (p != null) {        	p.stop();	                	p = null;        }	            	        if (p2 != null) {        	p2.stop();           	p2 = null;        }	
    } catch (Exception io) {
	    io.printStackTrace();     	
    }
	}
	    class MidThread extends Thread {    	    	String name,pid;    	    	public MidThread( String num )    	{    		name = num;    		    		if (name == "mid"){    			pid = "audio/midi";    			    		} else if (name == "mmf"){    			pid = "application/vnd.smaf";    			    			    			    		} else if (name == "amr"){    			pid = "audio/amr";    			    			    		} else if (name == "wav"){    			pid = "audio/x-wav";    			    			    		} else if (name == "dat"){    			pid = "audio/x-tone-seq";    			    			    		}    	}    	    	public void run(){       		
    		try     		{
    		String nthURL=name+"play."+name;    		String url = "resource:/audio/"+nthURL;    		System.out.println("url:"+url);    		if (is == null) {  		
        		is = getClass().getResourceAsStream(url.substring(9));        	        	System.out.println("is:"+url.substring(9));          	} else if (is2 == null) {        		is2 = getClass().getResourceAsStream(url.substring(9));        		System.out.println("is2:"+url.substring(9));          	}	

    		} catch (Exception ex){    	        ex.printStackTrace();	
    		}


 			try 			{ 			if (p == null) {	
     			p = Manager.createPlayer(is,pid);	        	System.out.println("----------createplayer-----------");     		
//	     		p.prefetch(); // opens the MIDI device
//     		MIDIControl m = (MIDIControl)p.getControl("MIDIControl");							System.out.println("----------getControl-----------");     		
	        	p.start();		            System.out.println("----------p.start----------");             } else if (p != null) {     			p2 = Manager.createPlayer(is2,pid);	        	System.out.println("----------createplayer2-----------");     		
//	     		p2.prefetch(); // opens the MIDI device
//     		MIDIControl m = (MIDIControl)p.getControl("MIDIControl");							System.out.println("----------getControl2-----------");     		
	        	p2.start();		            System.out.println("----------p2.start----------");         	}	     		       	
			} catch (IOException ioe) {
				ioe.printStackTrace(); 		 			} catch (MediaException me){ 		        me.printStackTrace(); 			}
    	}    		}
}

⌨️ 快捷键说明

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