亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? basicplayer.java

?? Eclipse高級(jí)編程3源碼(書本源碼)
?? JAVA
?? 第 1 頁 / 共 2 頁
字號(hào):
package javazoom.jlGui;

/**
 * BasicPlayer.
 *
 *-----------------------------------------------------------------------
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License as published
 *   by the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Library General Public License for more details.
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *----------------------------------------------------------------------
 */
import java.io.*;
import java.util.*;
import	java.net.URL;

import	javax.sound.sampled.AudioFormat;
import  javax.sound.sampled.AudioFileFormat;
import	javax.sound.sampled.AudioInputStream;
import	javax.sound.sampled.AudioSystem;
import	javax.sound.sampled.DataLine;
import	javax.sound.sampled.LineUnavailableException;
import	javax.sound.sampled.SourceDataLine;
import	javax.sound.sampled.UnsupportedAudioFileException;
import	javax.sound.sampled.FloatControl;
import	javax.sound.sampled.Control;
import 	javazoom.Util.Debug;

/**
 * BasicPlayer implements basics features of a player. The playback is done
 * with a thread.
 * BasicPlayer is the result of jlGui 0.5 from JavaZOOM and BaseAudioStream
 * from Matthias Pfisterer JavaSound examples.
 *
 * @author	E.B from JavaZOOM
 *
 * Homepage : http://www.javazoom.net
 *
 */
public class BasicPlayer implements Runnable
{

	private static final int		EXTERNAL_BUFFER_SIZE = 4000 * 4;

	private Thread					m_thread = null;
	private Object					m_dataSource;
	private AudioInputStream		m_audioInputStream;
	private AudioFileFormat			m_audioFileFormat;
	private SourceDataLine			m_line;
	private FloatControl			m_gainControl;
	private FloatControl			m_panControl;

	/**
	 * These variables are used to distinguish stopped, paused, playing states.
	 * We need them to control Thread.
	 */
	public static final int			PAUSED=1;
	public static final int			PLAYING=0;
	public static final int			STOPPED=2;
	public static final int			READY=3;
	private int						m_status = READY;
	private	long					doSeek = -1;
	private File					_file = null;
	private BasicPlayerListener		m_bpl = null;

	/**
	 * Constructs a Basic Player.
	 */
	public BasicPlayer()
	{
		m_dataSource = null;
		m_audioInputStream = null;
		m_audioFileFormat = null;
		m_line = null;
		m_gainControl = null;
		m_panControl = null;
	}

	/**
	 * Constructs a Basic Player with a BasicPlayerListener.
	 */
	public BasicPlayer(BasicPlayerListener bpl)
	{
		this();
		m_bpl = bpl;
	}

	/**
	 * Returns BasicPlayer status.
	 */
	public int getStatus()
	{
		return 	m_status;
	}

	/**
	 * Sets the data source as a file.
	 */
	public void setDataSource(File file) throws UnsupportedAudioFileException, LineUnavailableException, IOException
	{
		if (file != null)
		{
			m_dataSource = file;
			initAudioInputStream();
		}
	}


	/**
	 * Sets the data source as an url.
	 */
	public void setDataSource(URL url) throws UnsupportedAudioFileException, LineUnavailableException, IOException
	{
		if (url != null)
		{
			m_dataSource = url;
			initAudioInputStream();
		}
	}


	/**
	 * Inits Audio ressources from the data source.<br>
	 * - AudioInputStream <br>
	 * - AudioFileFormat
	 */
	private void initAudioInputStream() throws UnsupportedAudioFileException, LineUnavailableException, IOException
	{
		if (m_dataSource instanceof URL)
		{
			initAudioInputStream((URL) m_dataSource);
		}
		else if (m_dataSource instanceof File)
		{
			initAudioInputStream((File) m_dataSource);
		}
	}

	/**
	 * Inits Audio ressources from file.
	 */
	private void initAudioInputStream(File file) throws	UnsupportedAudioFileException, IOException
	{
		_file = file;
		m_audioInputStream = AudioSystem.getAudioInputStream(file);
		m_audioFileFormat = AudioSystem.getAudioFileFormat(file);
	}

	/**
	 * Inits Audio ressources from URL.
	 */
	private void initAudioInputStream(URL url) throws UnsupportedAudioFileException, IOException
	{
		m_audioInputStream = AudioSystem.getAudioInputStream(url);
		m_audioFileFormat = AudioSystem.getAudioFileFormat(url);
	}

	/**
	 * Inits Audio ressources from AudioSystem.<br>
	 * DateSource must be present.
	 */
	protected void initLine() throws LineUnavailableException
	{
		if (m_line == null)
		{
			createLine();
			trace(1,getClass().getName(), "Create Line OK ");
			openLine();
		}
		else
		{
			AudioFormat	lineAudioFormat = m_line.getFormat();
			AudioFormat	audioInputStreamFormat = m_audioInputStream == null ? null : m_audioInputStream.getFormat();
			if (!lineAudioFormat.equals(audioInputStreamFormat))
			{
				m_line.close();
				openLine();
			}
		}
	}

	/**
	 * Inits a DateLine.<br>
	 *
	 * We check if the line supports Volume and Pan controls.
	 *
	 * From the AudioInputStream, i.e. from the sound file, we
	 * fetch information about the format of the audio data. These
	 * information include the sampling frequency, the number of
	 * channels and the size of the samples. There information
	 * are needed to ask JavaSound for a suitable output line
	 * for this audio file.
	 * Furthermore, we have to give JavaSound a hint about how
	 * big the internal buffer for the line should be. Here,
	 * we say AudioSystem.NOT_SPECIFIED, signaling that we don't
	 * care about the exact size. JavaSound will use some default
	 * value for the buffer size.
	 */
	private void createLine() throws LineUnavailableException
	{
		if (m_line == null)
		{
			AudioFormat	sourceFormat = m_audioInputStream.getFormat();
			trace(1,getClass().getName(), "Source format : ", sourceFormat.toString());
			AudioFormat	targetFormat = new AudioFormat( AudioFormat.Encoding.PCM_SIGNED,
														sourceFormat.getSampleRate(),
														16,
														sourceFormat.getChannels(),
														sourceFormat.getChannels() * 2,
														sourceFormat.getSampleRate(),
														false);

			trace(1,getClass().getName(), "Target format: " + targetFormat);
			m_audioInputStream = AudioSystem.getAudioInputStream(targetFormat, m_audioInputStream);
			AudioFormat audioFormat = m_audioInputStream.getFormat();
			trace(1,getClass().getName(), "Create Line : ", audioFormat.toString());
			DataLine.Info	info = new DataLine.Info(SourceDataLine.class, audioFormat, AudioSystem.NOT_SPECIFIED);
			m_line = (SourceDataLine) AudioSystem.getLine(info);

			/*-- Display supported controls --*/
			Control[] c = m_line.getControls();
			for (int p=0;p<c.length;p++)
			{
				trace(2,getClass().getName(), "Controls : "+c[p].toString());
			}
			/*-- Is Gain Control supported ? --*/
			if (m_line.isControlSupported(FloatControl.Type.MASTER_GAIN))
			{
				m_gainControl = (FloatControl) m_line.getControl(FloatControl.Type.MASTER_GAIN);
				trace(1,getClass().getName(), "Master Gain Control : ["+m_gainControl.getMinimum()+","+m_gainControl.getMaximum()+"]",""+m_gainControl.getPrecision());
			}

			/*-- Is Pan control supported ? --*/
			if (m_line.isControlSupported(FloatControl.Type.PAN))
			{
				m_panControl = (FloatControl) m_line.getControl(FloatControl.Type.PAN);
				trace(1,getClass().getName(), "Pan Control : ["+ m_panControl.getMinimum()+","+m_panControl.getMaximum()+"]",""+m_panControl.getPrecision());
			}
		}
	}


	/**
	 * Opens the line.
	 */
	private void openLine() throws LineUnavailableException
	{
		if (m_line != null)
		{
			AudioFormat	audioFormat = m_audioInputStream.getFormat();
			trace(1,getClass().getName(), "AudioFormat : "+audioFormat);
			m_line.open(audioFormat, m_line.getBufferSize());
		}
	}

	/**
	 * Stops the playback.<br>
	 *
	 * Player Status = STOPPED.<br>
	 * Thread should free Audio ressources.
	 */
	public void stopPlayback()
	{
		if ( (m_status == PLAYING) || (m_status == PAUSED) )
		{
			if (m_line != null)
			{
				m_line.flush();
				m_line.stop();
			}
			m_status = STOPPED;
			trace(1,getClass().getName(), "Stop called");
		}
	}

	/**
	 * Pauses the playback.<br>
	 *
	 * Player Status = PAUSED.
	 */
	public void pausePlayback()
	{
		if (m_line != null)
		{
			if (m_status == PLAYING)
			{
				m_line.flush();
				m_line.stop();
				m_status = PAUSED;
				trace(1,getClass().getName(), "Pause called");
			}
		}
	}

	/**
	 * Resumes the playback.<br>
	 *
	 * Player Status = PLAYING.
	 */
	public void resumePlayback()
	{
		if (m_line != null)
		{
			if (m_status == PAUSED)
			{
				m_line.start();
				m_status = PLAYING;
				trace(1,getClass().getName(), "Resume called");
			}
		}
	}

	/**
	 * Starts playback.
	 */
	public String startPlayback()
	{
		if ((m_status == STOPPED) || (m_status == READY))
		{
			trace(1,getClass().getName(), "Start called");
			if (!(m_thread == null || !m_thread.isAlive()))
			{
				trace(1,getClass().getName(), "WARNING: old thread still running!!");
				int cnt = 0;
				while (m_status != READY)
				{
					try
					{
						if (m_thread != null)
						{
							cnt++;
							m_thread.sleep(1000);
							if (cnt > 2) m_thread.interrupt();
						}
					} catch (Exception e)
					  {
						  trace(1,getClass().getName(), "Waiting Error : "+e.getMessage());
					  }
					trace(1,getClass().getName(), "Waiting ... "+cnt);
				}
			}
			try
			{
				initLine();
			} catch (Exception e)
			  {
				  trace(0,getClass().getName(), "Cannot init Line",e.getMessage());
				  //e.printStackTrace();
				  return "ERROR";
			  }
			trace(1,getClass().getName(), "Creating new thread");
			m_thread = new Thread(this);
			m_thread.start();
			if (m_line != null)
			{
				m_line.start();
			}
		}
		return null;
	}

	/**
	 * Main loop.
	 *
	 * Player Status == STOPPED => End of Thread + Freeing Audio Ressources.<br>
	 * Player Status == PLAYING => Audio stream data sent to Audio line.<br>
	 * Player Status == PAUSED => Waiting for another status.
	 */
	public void run()
	{
		trace(1,getClass().getName(), "Thread Running");
		//if (m_audioInputStream.markSupported()) m_audioInputStream.mark(m_audioFileFormat.getByteLength());
		//else trace(1,getClass().getName(), "Mark not supported");
		int	nBytesRead = 1;
		m_status = PLAYING;

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品久久久久9999吃药| 中文字幕国产精品一区二区| 国产盗摄一区二区| 一区二区三区免费看视频| 精品久久国产字幕高潮| 99久久国产综合精品色伊 | 一区二区国产视频| 精品国免费一区二区三区| 色噜噜狠狠一区二区三区果冻| 国产自产2019最新不卡| 亚洲不卡av一区二区三区| 日本一区二区综合亚洲| 欧美一级专区免费大片| 91久久线看在观草草青青| 丁香婷婷深情五月亚洲| 免费成人av在线| 婷婷综合另类小说色区| 综合激情成人伊人| 日本一区二区免费在线 | 日韩不卡在线观看日韩不卡视频| 欧美视频一区在线| 成人激情av网| 国产精品一区一区三区| 久久精品久久精品| 日韩高清不卡一区二区| 一区二区三区在线观看欧美| 《视频一区视频二区| 国产色产综合色产在线视频| 日韩免费在线观看| 91麻豆精品国产综合久久久久久| 精品va天堂亚洲国产| 777久久久精品| 欧美日韩精品久久久| 在线免费观看一区| 99re亚洲国产精品| 成人国产视频在线观看 | 欧美手机在线视频| 日本久久电影网| 色呦呦国产精品| 91精品福利视频| 欧美在线播放高清精品| 色婷婷香蕉在线一区二区| 99精品视频一区二区| jvid福利写真一区二区三区| 不卡电影一区二区三区| 不卡一卡二卡三乱码免费网站| 国产精品456露脸| 成人综合婷婷国产精品久久| 国产aⅴ综合色| av一二三不卡影片| 日本黄色一区二区| 欧美日韩免费视频| 欧美放荡的少妇| 日韩免费成人网| 久久精品一区二区三区不卡 | 国产精品91xxx| 高清成人免费视频| 99久久99久久精品国产片果冻| 91一区一区三区| 欧美在线影院一区二区| 欧美一区二区三区爱爱| 精品国产一区二区三区久久久蜜月| 26uuu另类欧美亚洲曰本| 国产婷婷色一区二区三区四区| 国产精品免费久久| 一区二区三区美女| 蜜桃视频在线观看一区| 国产成人av在线影院| 日本精品裸体写真集在线观看| 亚洲乱码国产乱码精品精小说| 亚洲一区二区三区不卡国产欧美| 日韩国产欧美三级| 国产福利一区二区三区视频 | 国产精品女主播av| 一区二区三区在线视频免费| 日韩电影在线观看一区| 国产精品自拍网站| 色噜噜夜夜夜综合网| 91精品国产乱码久久蜜臀| 国产亚洲欧美一级| 亚洲午夜精品17c| 久久99精品久久久| 91视频在线看| 日韩美女在线视频| 亚洲欧美另类图片小说| 日本在线不卡一区| www.亚洲人| 欧美一级片在线观看| 中文字幕色av一区二区三区| 亚洲不卡在线观看| 成人h精品动漫一区二区三区| 欧美视频在线一区二区三区 | 亚洲国产精品人人做人人爽| 九九视频精品免费| 色综合久久66| 国产亚洲精品福利| 日韩高清电影一区| 色94色欧美sute亚洲线路一久| 欧美电影免费观看高清完整版在线| 中文字幕人成不卡一区| 久久精品理论片| 欧美少妇xxx| 中文字幕亚洲不卡| 韩日av一区二区| 欧美日本免费一区二区三区| 国产欧美日韩在线| 九九视频精品免费| 欧美日韩日本视频| 欧美色区777第一页| 国产精品欧美久久久久一区二区| 日本不卡一二三| 在线日韩一区二区| 亚洲视频每日更新| 国产精品一区二区三区四区| 91精品国产色综合久久不卡蜜臀 | 久久综合久久综合亚洲| 亚洲午夜av在线| 91亚洲午夜精品久久久久久| 国产性做久久久久久| 麻豆久久一区二区| 69久久夜色精品国产69蝌蚪网| 亚洲欧美日韩国产成人精品影院| 国产精品一区二区果冻传媒| 日韩精品一区二区三区在线观看| 亚洲aaa精品| 日本韩国一区二区三区| 亚洲免费伊人电影| 成人av免费在线观看| 国产色产综合色产在线视频| 国产一区二区0| 欧美精品一区二区精品网| 奇米影视在线99精品| 在线播放91灌醉迷j高跟美女| 亚洲一二三区不卡| 欧美日韩视频在线第一区| 亚洲最新在线观看| 欧美在线视频日韩| 亚洲小说春色综合另类电影| 欧美视频一区二区三区四区| 亚洲国产精品一区二区久久| 欧美午夜精品理论片a级按摩| 一区二区三区成人| 欧美午夜精品一区二区蜜桃| 亚洲一区二区三区在线播放| 欧美亚洲愉拍一区二区| 亚洲福利一二三区| 91精品欧美一区二区三区综合在| 日韩二区三区四区| 精品国产凹凸成av人导航| 狠狠色丁香久久婷婷综合_中| 久久久午夜精品| 成人中文字幕电影| 国产69精品久久久久777| 国产视频一区二区在线观看| 成人精品一区二区三区四区 | 美国av一区二区| 日韩欧美三级在线| 国产一区二区女| 中文字幕在线不卡一区| 色天天综合久久久久综合片| 午夜精品福利一区二区蜜股av| 91精品黄色片免费大全| 精品一区二区三区日韩| 中文成人av在线| 欧美综合亚洲图片综合区| 欧美aⅴ一区二区三区视频| 欧美电影免费观看高清完整版| 国产精品一区二区在线看| 亚洲男人的天堂在线观看| 欧美三级欧美一级| 国产一区二区视频在线播放| 中文字幕一区二区视频| 7777精品伊人久久久大香线蕉的| 极品美女销魂一区二区三区免费| 国产精品区一区二区三区| 91成人在线精品| 激情综合网最新| √…a在线天堂一区| 日韩免费视频一区| 北条麻妃国产九九精品视频| 亚洲不卡av一区二区三区| 国产亚洲视频系列| 欧美日韩国产天堂| 国产精品99久久久久久似苏梦涵| 亚洲综合色自拍一区| www欧美成人18+| 欧美日韩在线免费视频| 国产精品18久久久久久vr| 午夜免费久久看| 国产精品日韩成人| 日韩视频在线永久播放| 97久久超碰国产精品| 精品亚洲成a人| 亚洲第一av色| 自拍偷拍国产精品| 久久久久国产精品厨房| 欧美丰满少妇xxxxx高潮对白 | 欧美一区二区精美| 色哟哟精品一区| 国产成人在线电影|