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

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

?? player.java

?? Eclipse高級編程3源碼(書本源碼)
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/*******************************************************************************
 * Copyright (c) 2004 Berthold Daum. All rights reserved. This program and the
 * accompanying materials are made available under the terms of the Common
 * Public License v1.0 which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v10.html
 * 
 * Contributors: Berthold Daum
 ******************************************************************************/
package com.bdaum.jukebox;

import java.io.File;
import java.io.IOException;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
import javazoom.jlGui.BasicPlayer;
import javazoom.jlGui.BasicPlayerListener;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.*;

/**
 * Player module. This module demonstrates the various techniques of the SWT, in
 * particular the coordination between SWT thread and other threads.
 */
public class Player implements BasicPlayerListener {

	// Operation states
	private static final int PLAY = 1;

	private static final int PAUSE = 2;

	private static final int STOP = 3;

	private static final int EOM = 4;

	// Text representation of operation state
	private static final String PLAYING = "Playing";

	private static final String PAUSED = "Paused";

	private static final String IDLE = "Idle";

	// Features in the playlist data model
	public final static String TITLE = "title";

	public final static String SOUNDFILE = "soundfile";

	public final static String IMAGEFILE = "image";

	public final static String DESCRIPTION = "description";

	/* Data model of the player model */

	// Current operation state
	private int state = STOP;

	// The player engine
	private BasicPlayer soundPlayer;

	// The playlist's data model
	private IPlaylist playlistModel;

	// Duration of current tune
	private double lengthInSec = 0;

	// Current position
	private int currentPosition = 0;

	// Maximum position
	private int maxPosition = 0;

	// Text representation of current operation state
	private String mediaState = "Stopped";

	// Current background image
	private String currentImage;

	// Title of current tune
	private String currentTitle = "";

	/** * GUI elements ** */
	/* Widgets of player windows */

	// Player shell
	private Shell toplevelShell;

	// Outline of shell
	private static final int[] OUTLINE = new int[] { 5, 0, 355, 0, 360, 5, 360,
			20, 330, 295, 325, 300, 15, 290, 10, 285, 0, 5 };

	// The hole in the shell
	private static final int[] HOLLOW = new int[] { 13, 10, 247, 10, 250, 13,
			255, 27, 252, 30, 13, 30, 10, 27, 10, 13 };

	// Current Display instance
	private Display display;

	// Canvas for background image
	private Canvas canvas;

	// Taste zum Schlie遝n der Shell
	private Button closeButton;

	// Status Panel
	private Composite statusPanel;

	private Label statusLabel, lengthLabel;

	// Toolbar with buttons
	private ToolBar toolbar;

	private ToolItem backButton, playButton, pauseButton, stopButton,
			forwardButton, playlistButton, descriptionButton;

	// Scale
	private Scale scale;

	// Additional windows
	private DescriptionWindow descriptionWindow;

	private PlaylistWindow playlistWindow;

	/**
	 * main method for starting the player
	 * 
	 * @param args
	 *            unused
	 */
	public static void main(String args[]) {
		Player player = new Player();
		player.run();
	}

	/**
	 * Initialize Player
	 */
	private void run() {
		// Create Playlist domain model
		playlistModel = new PlaylistModel();
		// Create Display instance
		display = new Display();
		// Create top level shell with the usual controls
		toplevelShell = new Shell(display, SWT.NO_TRIM);
		// Set title (appears in tasks bar)
		toplevelShell.setText("Jukebox");
		// Hintergrundfarbe setzen
		Color bgColor = new Color(display, 160, 160, 255);
		toplevelShell.setBackground(bgColor);
		// Create region for the player shell outline
		Region region = new Region();
		region.add(OUTLINE);
		region.subtract(HOLLOW);
		// Apply region to shell
		toplevelShell.setRegion(region);
		// Retrieve size of region
		Rectangle size = region.getBounds();
		// Position shell on the primary monitor
		Monitor mon1 = display.getPrimaryMonitor();
		Rectangle r = mon1.getClientArea();
		toplevelShell.setBounds(r.x + 20, r.y + 20, size.width, size.height);
		// Since the shell does not have a trim
		// we must handle the repositioning of the window ourselves
		Listener listener = new Listener() {
			Point origin;

			public void handleEvent(Event e) {
				switch (e.type) {
				case SWT.MouseDown:
					// Remember mouse position
					origin = new Point(e.x, e.y);
					break;
				case SWT.MouseUp:
					// Indicate operation stopped
					origin = null;
					break;
				case SWT.MouseMove:
					if (origin != null) {
						// Shift shell by difference to origin
						Point p = display.map(toplevelShell, null, e.x, e.y);
						toplevelShell.setLocation(p.x - origin.x, p.y
								- origin.y);
					}
					break;
				}
			}
		};
		toplevelShell.addListener(SWT.MouseDown, listener);
		toplevelShell.addListener(SWT.MouseUp, listener);
		toplevelShell.addListener(SWT.MouseMove, listener);
		// Create rest of Player GUI
		constructPlayer(toplevelShell);
		// Create the jlGui-engine
		soundPlayer = new BasicPlayer(this);
		// Display shell
		toplevelShell.open();
		// Event loop
		while (!toplevelShell.isDisposed()) {
			// Check for waiting events
			if (!display.readAndDispatch())
				display.sleep();
		}
		// If necessary stop playing
		stop();
		// Force session exit -
		// otherwise the Java audio system would remain active
		System.exit(0);
	}

	/**
	 * Retrieves the playlist
	 * 
	 * @return IPlaylist - the playlist model
	 */
	public IPlaylist getPlaylist() {
		return playlistModel;
	}

	/** * GUI erzeugen ** */
	/**
	 * Constructs the Player-GUI.
	 * 
	 * @param parent
	 *            containing Composite
	 */
	private void constructPlayer(Composite parent) {
		// We use a GridLayout for the containing Composite
		GridLayout gridLayout = new GridLayout();
		gridLayout.marginHeight = 0;
		parent.setLayout(gridLayout);
		// Composite for CloseButton and StatusPanel
		Composite comp = new Composite(parent, SWT.NONE);
		gridLayout = new GridLayout(2, false);
		gridLayout.marginWidth = 10;
		comp.setLayout(gridLayout);
		comp.setBackground(parent.getBackground());
		// Layoutdaten for Composite
		GridData data = new GridData();
		data.horizontalAlignment = GridData.END;
		data.verticalAlignment = GridData.BEGINNING;
		data.grabExcessHorizontalSpace = true;
		comp.setLayoutData(data);
		// Create status panel
		createStatusPanel(comp);
		// Create button for closing the window
		createCloseButton(comp);
		// Create canvas
		canvas = new Canvas(parent, SWT.NONE);
		// Set preferred canvas size
		data = new GridData();
		data.widthHint = 355;
		data.heightHint = 235;
		canvas.setLayoutData(data);
		// The Canvas instance acts as a Composite, too.
		// So we apply a GridLayout to it, too.
		gridLayout = new GridLayout();
		gridLayout.marginHeight = 2;
		gridLayout.verticalSpacing = 0;
		canvas.setLayout(gridLayout);
		// Construct Toolbar
		createToolbar(canvas);
		// Construct scale
		createScale(canvas);
		// Add PaintListener to Canvas to support drawing
		canvas.addPaintListener(new PaintListener() {
			public void paintControl(PaintEvent e) {
				paintCanvas(e.gc);
			}
		});
		// Add MouseTrackListener to Canvas
		canvas.addMouseTrackListener(new MouseTrackAdapter() {
			public void mouseEnter(MouseEvent e) {
				setCanvasControlsVisible(true);
			}

			public void mouseExit(MouseEvent e) {
				Rectangle rect = canvas.getClientArea();
				// Check if mouse has really left the canvas area
				if (!rect.contains(e.x, e.y))
					setCanvasControlsVisible(false);
			}
		});
		setCanvasControlsVisible(false);
	}

	/**
	 * Create window close button
	 * 
	 * @param parent
	 *            the containing Composite
	 */
	private void createCloseButton(Composite parent) {
		closeButton = new Button(parent, SWT.PUSH | SWT.FLAT);
		closeButton.setText("x");
		closeButton.addListener(SWT.Selection, new Listener() {
			public void handleEvent(Event e) {
				toplevelShell.close();
			}
		});
	}

	/**
	 * Shows or hides the control elements on top of the canvas.
	 * 
	 * @param v
	 *            true for showing, false for hiding
	 */
	private void setCanvasControlsVisible(boolean v) {
		toolbar.setVisible(v);
		scale.setVisible(v);
	}

	/** * Graphic Operations ** */
	/**
	 * Draw all graphical elements on the canvas.
	 * 
	 * @param gc
	 *            The graphics context
	 */
	private void paintCanvas(GC gc) {
		Rectangle area = canvas.getClientArea();
		// Check if we have an image file
		if (doesFileExist(currentImage)) {
			// Scale and draw image
			Image image = new Image(display, currentImage);
			Rectangle bounds = image.getBounds();
			gc.drawImage(image, bounds.x, bounds.y, bounds.width,
					bounds.height, area.x, area.y, area.width, area.height);
			// Dispose image
			image.dispose();
		} else {
			// Otherwise fill background with gray color
			gc.setBackground(toplevelShell.getBackground());
			gc.fillRectangle(area);
		}
		// Draw title of current sound file
		if (currentTitle != null && currentTitle.length() > 0) {
			gc.setBackground(display.getSystemColor(SWT.COLOR_DARK_GRAY));
			gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
			gc.drawText(" " + currentTitle + " ", 5, 12, false);
		}
	}

	/**
	 * Checks if a file with the specified name exists.
	 * 
	 * @param filename
	 *            File name
	 * @return boolean - true, if the file exists
	 */
	private static boolean doesFileExist(String filename) {
		return (filename != null && filename.length() > 0 && openFile(filename)
				.exists());
	}

	/**
	 * Convert file name into File instance
	 * 
	 * @param file
	 *            File name
	 * @return File - File instance
	 */
	private static File openFile(String file) {
		return new File(file);
	}

	/** * Instrument Canvas ** */
	/**
	 * Creates a scale that shows the current position in the sound file.
	 * 
	 * @param parent
	 *            the containing Composite
	 */
	private void createScale(Composite parent) {
		scale = new Scale(parent, SWT.NONE);
		// Set scale size
		GridData data = new GridData();
		data.horizontalIndent = 18;
		data.widthHint = 300;
		data.heightHint = 20;
		scale.setLayoutData(data);
		// Event processing for scale handle movements
		scale.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				seek();
			}
		});
	}

	/**
	 * Create toolbar with all buttons
	 * 
	 * @param parent
	 *            the containing Composite
	 */
	private void createToolbar(Composite parent) {
		// Create Toolbar instance
		toolbar = new ToolBar(parent, SWT.NONE);
		// Create all buttons
		backButton = makeToolItem(toolbar, SWT.PUSH, "<<", "Previous");
		playButton = makeToolItem(toolbar, SWT.PUSH, ">", "Play");
		pauseButton = makeToolItem(toolbar, SWT.PUSH, "||", "Pause");
		stopButton = makeToolItem(toolbar, SWT.PUSH, "[]", "Stop");
		forwardButton = makeToolItem(toolbar, SWT.PUSH, ">>", "Next");
		makeToolItem(toolbar, SWT.SEPARATOR, null, null);
		playlistButton = makeToolItem(toolbar, SWT.CHECK, "PlayList",
				"Show Playlist");
		descriptionButton = makeToolItem(toolbar, SWT.CHECK, "ShowText",
				"Show Description");

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线区一区二视频| 国产成人日日夜夜| 在线观看一区二区视频| 中文字幕一区二区三区在线不卡| 成人一级片在线观看| 国产精品传媒视频| 91搞黄在线观看| 五月婷婷欧美视频| 精品久久免费看| 国产91精品欧美| 久久激情五月婷婷| 精品国内片67194| 成人免费三级在线| 亚洲精品高清视频在线观看| 在线播放日韩导航| 极品美女销魂一区二区三区免费| 国产婷婷一区二区| 91美女片黄在线| 日韩电影一区二区三区| 亚洲精品一区二区三区99| 顶级嫩模精品视频在线看| 尤物视频一区二区| 欧美成人一区二区三区在线观看| 成人午夜免费视频| 五月天亚洲婷婷| 国产婷婷色一区二区三区四区| 99精品欧美一区二区三区小说| 亚洲成a人片综合在线| 久久综合资源网| 91视频免费播放| 精品一区二区三区的国产在线播放| 日本一区二区三区四区在线视频 | 中文字幕一区二区三中文字幕| 一本久久a久久精品亚洲| 日韩精品色哟哟| 亚洲视频精选在线| 欧美videossexotv100| 91丨porny丨国产| 久久99在线观看| 亚洲国产视频一区二区| 国产欧美日韩综合| 欧美一区二区黄色| 色婷婷久久久亚洲一区二区三区| 色狠狠一区二区| 激情综合网最新| 爽好多水快深点欧美视频| 国产精品国产三级国产| 久久综合久久综合亚洲| 欧美日韩在线三级| 99精品视频一区二区| 精品写真视频在线观看| 午夜电影网一区| 亚洲日本青草视频在线怡红院| 久久色中文字幕| 日韩一区二区三区视频| 欧美亚一区二区| 成人av网站在线观看| 久久国产乱子精品免费女| 亚洲动漫第一页| 亚洲男女毛片无遮挡| 日本一区二区综合亚洲| 欧美色手机在线观看| 欧美一级艳片视频免费观看| 91在线无精精品入口| 国产高清无密码一区二区三区| 天天av天天翘天天综合网| 亚洲精品乱码久久久久久久久 | bt7086福利一区国产| 国产一区免费电影| 蜜桃精品视频在线| 日韩av一区二区在线影视| 亚洲福利视频一区| 亚洲高清免费观看| 亚洲一区二区三区激情| 亚洲黄网站在线观看| 一区二区三区免费| 一二三区精品福利视频| 一区二区三区在线免费| 一区二区三区在线看| 亚洲影院在线观看| 亚洲国产日韩a在线播放性色| 一区二区三区四区乱视频| 亚洲男人的天堂在线观看| 亚洲精品视频自拍| 一区二区三区在线影院| 亚洲一二三专区| 爽好久久久欧美精品| 日本免费新一区视频| 精品影视av免费| 国模一区二区三区白浆| 福利一区二区在线| 99精品视频在线免费观看| 色视频成人在线观看免| 欧美日本精品一区二区三区| 中文字幕在线观看不卡| 一区二区三区毛片| 视频一区二区国产| 精品亚洲aⅴ乱码一区二区三区| 国产在线视频不卡二| 成人黄色在线视频| 91啦中文在线观看| 欧美福利视频一区| 久久精品免视看| 亚洲丝袜美腿综合| 视频一区二区三区中文字幕| 狠狠狠色丁香婷婷综合激情| 成人中文字幕在线| 欧美在线观看你懂的| 日韩写真欧美这视频| 日本一区二区综合亚洲| 亚洲综合在线免费观看| 美国一区二区三区在线播放| 国产精品羞羞答答xxdd| 一本色道a无线码一区v| 日韩一区二区电影在线| 国产精品久久一卡二卡| 日韩精品福利网| 成人国产精品免费观看视频| 欧美丝袜丝nylons| 26uuu精品一区二区| 有码一区二区三区| 韩国精品主播一区二区在线观看 | 不卡av电影在线播放| 欧美精品v日韩精品v韩国精品v| 精品盗摄一区二区三区| 亚洲天堂精品视频| 久久av老司机精品网站导航| 99久久婷婷国产综合精品| 欧美一区二区三区免费在线看| 国产精品卡一卡二| 麻豆视频观看网址久久| 色哟哟欧美精品| 国产无人区一区二区三区| 亚洲第一二三四区| 成人av网址在线| 久久久亚洲精品石原莉奈| 亚洲一区二区三区影院| 国产成人福利片| 欧美一区二区三区四区五区| 国产精品剧情在线亚洲| 韩国av一区二区三区| 欧美日韩一区二区三区高清 | 日本不卡一区二区| 色婷婷亚洲一区二区三区| 久久久久久久久久久久久女国产乱| 偷窥国产亚洲免费视频| 91免费版在线| 国产精品久久精品日日| 国模娜娜一区二区三区| 欧美一级黄色大片| 天天影视色香欲综合网老头| 色综合天天综合| 国产精品乱码一区二三区小蝌蚪| 久久99久久久久久久久久久| 欧美日韩精品三区| 亚洲一区二区三区精品在线| 色成年激情久久综合| 国产精品久久久久9999吃药| 国产成人精品免费网站| 精品电影一区二区三区| 麻豆国产欧美日韩综合精品二区| 欧美伦理视频网站| 午夜久久久影院| 91麻豆精品国产91久久久资源速度| 亚洲乱码中文字幕综合| 成人性色生活片免费看爆迷你毛片| 久久久www免费人成精品| 久久97超碰国产精品超碰| 日韩欧美一二三四区| 免费观看在线综合| 欧美一级高清片| 久久99精品久久久久久久久久久久 | 视频在线观看国产精品| 欧美日本一区二区在线观看| 性欧美疯狂xxxxbbbb| 91精品一区二区三区在线观看| 三级成人在线视频| 日韩丝袜情趣美女图片| 久久精品国产网站| 久久久久综合网| 成人av高清在线| 亚洲婷婷综合色高清在线| 在线观看视频一区二区欧美日韩| 一区二区三区不卡视频| 欧美丰满少妇xxxbbb| 久久综合综合久久综合| 久久中文娱乐网| 99久久综合狠狠综合久久| 亚洲精品成人a在线观看| 欧美中文一区二区三区| 免费人成黄页网站在线一区二区| 精品欧美一区二区久久| 成人小视频在线| 亚洲午夜久久久久久久久久久 | 欧美成人性战久久| 成人天堂资源www在线| 一区二区欧美在线观看| 日韩一区二区三区四区| 成人综合婷婷国产精品久久免费| 一区二区三区欧美久久|