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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? basicplayer.java

?? java寫的MP3播放器
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
package javazoom.jlGui;

/**
 * BasicPlayer.
 *
 *-----------------------------------------------------------------------
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU 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 General Public License for more details.
 *
 *  You should have received a copy of the GNU 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.
	 */
	private static final int		PLAYING=0;
	private static final int		PAUSED=1;
	private static final int		STOPPED=2;
	private 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;
	}

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


	/**
	 * Sets the data source as an url.
	 */
	protected 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.
	 */
	protected 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!!");
				while (m_status != READY)
				{
					try
					{
						if (m_thread != null) m_thread.sleep(1000);
					} catch (Exception e)
					  {
						  trace(1,getClass().getName(), "Waiting Error : "+e.getMessage());
					  }
					trace(1,getClass().getName(), "Waiting ...");

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕在线播放不卡一区| 蜜臀av性久久久久蜜臀aⅴ流畅| 亚洲在线观看免费| 国产在线不卡视频| 欧美日韩1234| 亚洲精品va在线观看| 国产麻豆精品视频| 欧美一区二区三区色| 亚洲综合一区二区三区| 成人精品一区二区三区四区| 26uuu精品一区二区三区四区在线| 樱花影视一区二区| va亚洲va日韩不卡在线观看| 日韩欧美久久久| 男男成人高潮片免费网站| 色婷婷综合久久久久中文| 国产精品久久久久国产精品日日| 经典三级视频一区| 欧美电影免费提供在线观看| 日韩精品1区2区3区| 欧洲人成人精品| 亚洲综合在线第一页| 91免费精品国自产拍在线不卡| 日本一区二区三区视频视频| 国产精品一区二区果冻传媒| 欧美mv日韩mv国产网站app| 午夜精品久久久久久久蜜桃app| 在线观看亚洲一区| 一区二区三区蜜桃| 91成人免费在线视频| 亚洲一线二线三线视频| 91看片淫黄大片一级在线观看| 中文字幕一区二区三| 成人深夜在线观看| 国产精品成人在线观看| av亚洲精华国产精华| 亚洲少妇30p| 欧美专区在线观看一区| 天使萌一区二区三区免费观看| 欧美日韩一区二区在线视频| 视频一区二区中文字幕| 在线不卡中文字幕播放| 日韩电影免费在线看| 日韩女优电影在线观看| 国产在线看一区| 国产精品视频你懂的| 91香蕉视频污在线| 亚洲成人av电影在线| 4438x亚洲最大成人网| 久久精品久久久精品美女| 久久精品视频一区| 成人久久久精品乱码一区二区三区| 亚洲视频一区二区在线| 欧美日韩日日摸| 国内久久精品视频| 亚洲欧美日韩系列| 欧美精品第1页| 国产精品一线二线三线精华| 亚洲色图清纯唯美| 91麻豆精品国产| 国产风韵犹存在线视精品| 亚洲精品第1页| 日韩欧美不卡在线观看视频| 播五月开心婷婷综合| 亚洲成人激情综合网| 精品成人a区在线观看| 91在线观看地址| 麻豆精品一区二区av白丝在线| 国产免费成人在线视频| 欧美精品少妇一区二区三区| 国产成人精品亚洲午夜麻豆| 亚洲国产你懂的| 国产午夜精品一区二区三区视频| 欧美在线视频不卡| 国产伦精品一区二区三区在线观看 | 91一区二区在线观看| 秋霞国产午夜精品免费视频| 中文字幕av一区二区三区| 欧美卡1卡2卡| 91麻豆swag| 国产乱码精品一区二区三区忘忧草| 亚洲精品乱码久久久久久久久 | 国产成人午夜高潮毛片| 亚洲18色成人| 国产精品毛片高清在线完整版| 555www色欧美视频| 91女神在线视频| 国产美女精品人人做人人爽| 日韩国产欧美在线观看| 欧美国产97人人爽人人喊| 欧美一级欧美一级在线播放| 91久久精品国产91性色tv| 大胆亚洲人体视频| 精品亚洲porn| 图片区小说区国产精品视频| 中文字幕在线不卡视频| 久久久亚洲午夜电影| 日韩视频免费观看高清在线视频| 91久久线看在观草草青青| 99久久久久久| 不卡的av网站| www.日本不卡| 成人免费视频一区二区| 国产高清在线精品| 国产老妇另类xxxxx| 久久99最新地址| 麻豆精品在线视频| 蜜臀久久99精品久久久画质超高清| 亚洲国产精品一区二区尤物区| 亚洲男同1069视频| 中文字幕中文字幕中文字幕亚洲无线| 国产欧美一区二区在线观看| 国产女同互慰高潮91漫画| 2020国产精品自拍| 久久综合av免费| 久久精品视频一区| 国产精品久久毛片av大全日韩| 日韩一区在线播放| 国产精品传媒在线| 一区二区三区免费网站| 亚洲线精品一区二区三区| 一区二区欧美视频| 亚洲国产日韩精品| 久久精品国产99国产精品| 精品一区二区三区在线播放 | 青青青伊人色综合久久| 麻豆专区一区二区三区四区五区| 日韩av一区二区在线影视| 日韩国产在线观看| 国产一区二区美女诱惑| 成人丝袜视频网| 在线观看欧美日本| 91精品国产综合久久精品app| 日韩精品资源二区在线| 国产日韩精品一区二区三区在线| 国产精品久久久久一区二区三区 | 欧美一二三区在线观看| 日韩欧美成人激情| 国产精品久久影院| 五月婷婷另类国产| 国产精品亚洲人在线观看| www.综合网.com| 欧美精三区欧美精三区| 久久久另类综合| 亚洲综合男人的天堂| 麻豆成人免费电影| 波波电影院一区二区三区| 欧美另类videos死尸| 久久精品网站免费观看| 亚洲成人免费看| 国产盗摄一区二区| 欧美系列一区二区| 久久久影院官网| 亚洲国产欧美日韩另类综合| 国产精品正在播放| 欧美日韩午夜在线| 国产精品久线观看视频| 日本特黄久久久高潮| 91污在线观看| 26uuu久久天堂性欧美| 亚洲国产美国国产综合一区二区| 国产综合色在线| 欧美高清性hdvideosex| 国产精品第四页| 国产一区二区在线视频| 欧美色区777第一页| 中文字幕一区日韩精品欧美| 久久精品国产99国产| 欧美日韩亚洲另类| 亚洲欧美综合另类在线卡通| 久久国产视频网| 欧美日韩国产大片| 日韩美女视频19| 国产xxx精品视频大全| 日韩精品专区在线| 亚洲一区在线观看免费观看电影高清| 国产成人免费av在线| 欧美白人最猛性xxxxx69交| 亚洲一区二区四区蜜桃| 99国产精品国产精品久久| 日本一区二区免费在线观看视频| 精品无码三级在线观看视频| 欧美精品国产精品| 亚洲图片欧美一区| 99久久国产免费看| **欧美大码日韩| a亚洲天堂av| 亚洲四区在线观看| 91在线视频观看| 亚洲激情一二三区| 色狠狠综合天天综合综合| 亚洲免费观看高清完整版在线观看熊| 高清国产一区二区三区| 亚洲国产精品v| www.亚洲激情.com| 一区二区在线观看免费 | 亚洲精品乱码久久久久久| 99久久婷婷国产综合精品| 亚洲欧洲另类国产综合| 99精品久久只有精品|