「歌曲java」歌曲jambalaya
今天给各位分享歌曲java的知识,其中也会对歌曲jambalaya进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:
怎样在java中播放音乐
使用play()方法进行播放,loop()方法循环播放,stop()方法停止播放。
实际例子:
File file1 = new File("src\\music\\11.wav");
AudioClip sound1;
sound1 = Applet.newAudioClip(file1.toURL());
sound1.play();
这样就实现了播放音乐的功能,注意J2SE默认只支持 wav格式的音频。
Avalanche (Java) 歌词
歌曲名:Avalanche (Java)
歌手:Jo Privat
专辑:Dansez Avec Jo Privat
Manafest - Avalanche
Get me out, (out) get me out (out)
PREACHER, PREACHER what you got for me save my soul
See beneath, and clip my wings I'm not an angel
I try and try to be good, I've lied with pride I'm a crook
Turn the lights down, burning up the night now
Sign my life out, I'm sick of living here yo
If you can help choir boy ring the church bells
I'd turn back if I could, erase the pain if I could
But I'm an animal and I don't know if I can
Hey!!
Cause I'm the prodigal man of this avalanche
I'm going down, I'm going down, down
Hey!!!!
And if you turn me in
I'll confess my sins
I'm going down, I'm going down, down
Before I'm six feet deep
I'm washing my hands clean
Just get me out of this avalanche
You scared the junk-crap out of me man
The Ghost Rider, hold my soul tighter
Jehovah take the ropes I'm a
Fly a plane out of the atmosphere
I've attacked this fear
This scar still here
I'm going on to the end
I'm holding out to a friend
I'm going I'm going
I don't care
I cursed a lot
The worse, the black sheep of the lot
Christopher Scott prepare to meet God
Hey!!
Cause I'm the prodigal man of this avalanche
I'm going down, I'm going down, down
Hey!!!!
And if you turn me in
I'll confess my sins
I'm going down, I'm going down, down
Before I'm six feet deep
I'm washing my hands clean
Just get me out of this Avalanche
Get me out, OUT
Get me out, OUT
Just get me out of this avalanche
Get me out, OUT
Get me out, OUT
Just get me out of this...
You guided me when I was
Blind with pride a right off
Knocked me off my saddle
Sabotaged and overshadowed
Watched you chase a man down
Watched you raise a man out
Mercy on me, forever I'm free
Hey!!
Cause I'm the prodigal man of this avalanche
I'm going down, I'm going down, down
Hey!!!!
And if you turn me in
I'll confess my sins
I'm going down, I'm going down, down
Before I'm six feet deep
I'm washing my hands clean
Just get me out of this Avalanche
Get me out, OUT
Get me out, OUT
Just get me out of this avalanche
Get me out, OUT
Get me out, OUT
Just get me out of this...
怎样通过java打开音乐播放器
java中打开音乐播放器的方式是使用audioclip类来播放音乐,实例如下:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import javax.swing.*;
import java.io.File;
class AudioPlayDemo extends JFrame implements ActionListener {
boolean looping = false;
File file1 = new File("music\\明天会更好.wav");
AudioClip sound1;
AudioClip chosenClip;
JButton playButton = new JButton("播放");
JButton loopButton = new JButton("循环播放");
JButton stopButton = new JButton("停止");
JLabel status = new JLabel("选择播放文件");
JPanel controlPanel = new JPanel();
Container container = getContentPane();
public AudioPlayDemo() {
try {
sound1 = Applet.newAudioClip(file1.toURL());
chosenClip = sound1;
} catch(OutOfMemoryError e){
System.out.println("内存溢出");
e.printStackTrace();
} catch(Exception e){
e.printStackTrace();
}
playButton.addActionListener(this);
loopButton.addActionListener(this);
stopButton.addActionListener(this);
stopButton.setEnabled(false);
controlPanel.add(playButton);
controlPanel.add(loopButton);
controlPanel.add(stopButton);
container.add(controlPanel, BorderLayout.CENTER);
container.add(status, BorderLayout.SOUTH);
setSize(300, 130);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //关闭窗口时退出程序
}
public void actionPerformed(ActionEvent event) {
if (chosenClip == null) {
status.setText("声音未载入");
return;
}
Object source = event.getSource(); //获取用户洗涤激活的按钮
if (source == playButton) {
stopButton.setEnabled(true);
loopButton.setEnabled(true);
chosenClip.play();
status.setText("正在播放");
}
if (source == loopButton) {
looping = true;
chosenClip.loop();
loopButton.setEnabled(false);
stopButton.setEnabled(true);
status.setText("正在循环播放");
}
if (source == stopButton) {
if (looping) {
looping = false;
chosenClip.stop();
loopButton.setEnabled(true);
} else {
chosenClip.stop();
}
stopButton.setEnabled(false);
status.setText("停止播放");
}
}
public static void main(String s[]) {
new AudioPlayDemo();
}
}
只能播放wav格式的歌曲
java 获取歌曲文件的信息
这个具体的倒是不太清楚.不过你可以看看java开源播放器YOYOPlayer是如何实现的.以下是java开源播放器YOYOPlayer歌曲列表的实现,希望能对你有所帮助:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.hadeslee.yoyoplayer.playlist;
import com.hadeslee.yoyoplayer.util.*;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
import java.util.Vector;
/**
* 一个播放列表的基本实现
* @author hadeslee
*/
public class BasicPlayList implements PlayList {
private static final long serialVersionUID = 20071214L;
protected VectorPlayListItem playList;
protected int currentIndex = -1;
protected boolean isModified;
protected String M3UHome;//MP3U格式列表的位置
protected String PLSHome;//PLS格式列表的位置
private String name;//表示此播放列表的名字
private Config config;//全局的配置对象
private PlayListItem playing;//正在播放的项
public BasicPlayList(Config config) {
this.config = config;
playList = new VectorPlayListItem();
}
public boolean load(String filename) {
setModified(true);
boolean loaded = false;
if ((filename != null) (filename.toLowerCase().endsWith(".m3u"))) {
loaded = loadM3U(filename);
} else if ((filename != null) (filename.toLowerCase().endsWith(".pls"))) {
loaded = loadPLS(filename);
}
return loaded;
}
protected boolean loadM3U(String filename) {
boolean loaded = false;
BufferedReader br = null;
try {
// Playlist from URL ? (http:, ftp:, file: ....)
if (Config.startWithProtocol(filename)) {
br = new BufferedReader(new InputStreamReader((new URL(filename)).openStream()));
} else {
br = new BufferedReader(new FileReader(filename));
}
String line = null;
String songName = null;
String songFile = null;
String songLength = null;
while ((line = br.readLine()) != null) {
if (line.trim().length() == 0) {
continue;
}
if (line.startsWith("#")) {
if (line.toUpperCase().startsWith("#EXTINF")) {
int indA = line.indexOf(",", 0);
if (indA != -1) {
songName = line.substring(indA + 1, line.length());
}
int indB = line.indexOf(":", 0);
if (indB != -1) {
if (indB indA) {
songLength = (line.substring(indB + 1, indA)).trim();
}
}
}
} else {
songFile = line;
if (songName == null) {
songName = songFile;
}
if (songLength == null) {
songLength = "-1";
}
PlayListItem pli = null;
if (Config.startWithProtocol(songFile)) {
// URL.
pli = new PlayListItem(songName, songFile, Long.parseLong(songLength), false);
} else {
// File.
File f = new File(songFile);
if (f.exists()) {
pli = new PlayListItem(songName, songFile, Long.parseLong(songLength), true);
} else {
// Try relative path.
f = new File(config.getLastDir() + songFile);
if (f.exists()) {
pli = new PlayListItem(songName, config.getLastDir() + songFile, Long.parseLong(songLength), true);
} else {
// Try optional M3U home.
if (M3UHome != null) {
if (Config.startWithProtocol(M3UHome)) {
pli = new PlayListItem(songName, M3UHome + songFile, Long.parseLong(songLength), false);
} else {
pli = new PlayListItem(songName, M3UHome + songFile, Long.parseLong(songLength), true);
}
}
}
}
}
if (pli != null) {
this.appendItem(pli);
}
songFile = null;
songName = null;
songLength = null;
}
}
loaded = true;
} catch (Exception e) {
} finally {
try {
if (br != null) {
br.close();
}
} catch (Exception ioe) {
}
}
name = Util.getSongName(new File(filename));
return loaded;
}
protected boolean loadPLS(String filename) {
boolean loaded = false;
BufferedReader br = null;
try {
// Playlist from URL ? (http:, ftp:, file: ....)
if (Config.startWithProtocol(filename)) {
br = new BufferedReader(new InputStreamReader((new URL(filename)).openStream()));
} else {
br = new BufferedReader(new FileReader(filename));
}
String line = null;
String songName = null;
String songFile = null;
String songLength = null;
while ((line = br.readLine()) != null) {
if (line.trim().length() == 0) {
continue;
}
if ((line.toLowerCase().startsWith("file"))) {
StringTokenizer st = new StringTokenizer(line, "=");
st.nextToken();
songFile = st.nextToken().trim();
} else if ((line.toLowerCase().startsWith("title"))) {
StringTokenizer st = new StringTokenizer(line, "=");
st.nextToken();
songName = st.nextToken().trim();
} else if ((line.toLowerCase().startsWith("length"))) {
StringTokenizer st = new StringTokenizer(line, "=");
st.nextToken();
songLength = st.nextToken().trim();
}
// New entry ?
if (songFile != null) {
PlayListItem pli = null;
if (songName == null) {
songName = songFile;
}
if (songLength == null) {
songLength = "-1";
}
if (Config.startWithProtocol(songFile)) {
// URL.
pli = new PlayListItem(songName, songFile, Long.parseLong(songLength), false);
} else {
// File.
File f = new File(songFile);
if (f.exists()) {
pli = new PlayListItem(songName, songFile, Long.parseLong(songLength), true);
} else {
// Try relative path.
f = new File(config.getLastDir() + songFile);
if (f.exists()) {
pli = new PlayListItem(songName, config.getLastDir() + songFile, Long.parseLong(songLength), true);
} else {
// Try optional PLS home.
if (PLSHome != null) {
if (Config.startWithProtocol(PLSHome)) {
pli = new PlayListItem(songName, PLSHome + songFile, Long.parseLong(songLength), false);
} else {
pli = new PlayListItem(songName, PLSHome + songFile, Long.parseLong(songLength), true);
}
}
}
}
}
if (pli != null) {
this.appendItem(pli);
}
songName = null;
songFile = null;
songLength = null;
}
}
loaded = true;
} catch (Exception e) {
} finally {
try {
if (br != null) {
br.close();
}
} catch (Exception ioe) {
}
}
name = Util.getSongName(new File(filename));
return loaded;
}
public boolean save(String filename) {
// Implemented by C.K
if (playList != null) {
BufferedWriter bw = null;
try {
bw = new BufferedWriter(new FileWriter(filename));
bw.write("#EXTM3U");
bw.newLine();
IteratorPlayListItem it = playList.iterator();
while (it.hasNext()) {
PlayListItem pli = it.next();
bw.write("#EXTINF:" + pli.getM3UExtInf());
bw.newLine();
bw.write(pli.getLocation());
bw.newLine();
}
return true;
} catch (IOException e) {
} finally {
try {
if (bw != null) {
bw.close();
}
} catch (IOException ioe) {
}
}
}
return false;
}
public void addItemAt(PlayListItem pli, int pos) {
playList.add(pos, pli);
for (int i = 0; i playList.size(); i++) {
if (playList.get(i).isSelected()) {
currentIndex = i;
}
}
setModified(true);
if (Config.getConfig().getReadTagInfoStrategy().equals(Config.READ_WHEN_ADD)) {
pli.getTagInfo();
}
}
public void removeItem(PlayListItem pli) {
playList.remove(pli);
setModified(true);
for (int i = 0; i playList.size(); i++) {
if (playList.get(i).isSelected()) {
currentIndex = i;
}
}
}
public void removeItemAt(int pos) {
playList.remove(pos);
setModified(true);
for (int i = 0; i playList.size(); i++) {
if (playList.get(i).isSelected()) {
currentIndex = i;
}
}
}
public void removeAllItems() {
playList.clear();
currentIndex = -1;
setModified(true);
}
public void appendItem(PlayListItem pli) {
playList.add(pli);
setModified(true);
if (Config.getConfig().getReadTagInfoStrategy().equals(Config.READ_WHEN_ADD)) {
pli.getTagInfo();
}
}
public void sortItems(int sortmode) {
}
public PlayListItem getItemAt(int pos) {
if (pos playList.size() pos -1) {
return playList.get(pos);
}
return null;
}
public VectorPlayListItem getAllItems() {
return playList;
}
public int getPlaylistSize() {
return playList.size();
}
public void shuffle() {
int size = playList.size();
if (size 2) {
return;
}
ListPlayListItem v = playList;
playList = new VectorPlayListItem(size);
while ((size = v.size()) 0) {
playList.add(v.remove((int) (Math.random() * size)));
}
begin();
//此次可能不一定需要这个方法,因为本身此方法就是打
//乱播放列表的顺序,所以此时再点击下一首不一定就是
//当前播放的歌曲的下一首
for (int i = 0; i playList.size(); i++) {
if (playList.get(i).isSelected()) {
currentIndex = i;
}
}
}
public PlayListItem getCursor() {
if ((currentIndex 0) || (currentIndex = playList.size())) {
return null;
}
return getItemAt(currentIndex);
}
public void begin() {
currentIndex = -1;
if (getPlaylistSize() 0) {
currentIndex = 0;
}
setModified(true);
}
public int getSelectedIndex() {
return currentIndex;
}
public int getIndex(PlayListItem pli) {
return playList.indexOf(pli);
}
public void nextCursor() {
//如果是随机播放,则随机取一个下标
if (config.getPlayStrategy() == Config.RANDOM_PLAY) {
currentIndex = (int) (Math.random() * playList.size());
//否则就按顺序
} else if (config.getPlayStrategy() == Config.ORDER_PLAY) {
currentIndex++;
}
if (config.isRepeatEnabled() currentIndex = playList.size()) {
currentIndex = 0;
}
}
public void previousCursor() {
//如果是随机播放,则随机取一个下标
if (config.getPlayStrategy() == Config.RANDOM_PLAY) {
currentIndex = (int) (Math.random() * playList.size());
//否则就按顺序
} else if (config.getPlayStrategy() == Config.ORDER_PLAY) {
currentIndex--;
}
if (config.isRepeatEnabled() currentIndex 0) {
currentIndex = playList.size() - 1;
}
}
public boolean setModified(boolean set) {
return isModified = set;
}
public boolean isModified() {
return isModified;
}
public void setCursor(int index) {
currentIndex = index;
playing = playList.get(index);
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
/**
* Get M3U home for relative playlist.
*
* @return
*/
public String getM3UHome() {
return M3UHome;
}
/**
* Set optional M3U home for relative playlist.
*
* @param string
*/
public void setM3UHome(String string) {
M3UHome = string;
}
/**
* Get PLS home for relative playlist.
*
* @return
*/
public String getPLSHome() {
return PLSHome;
}
/**
* Set optional PLS home for relative playlist.
*
* @param string
*/
public void setPLSHome(String string) {
PLSHome = string;
}
public String toString() {
return name;
}
public void setItemSelected(PlayListItem pl, int index) {
if (pl == null) {
return;
}
// for (PlayListItem p : playList) {
// p.setSelected(false);
// }
// pl.setSelected(true);
this.currentIndex = index;
}
}
java歌曲排序
拿这里的数组进行举例吧。
musics原数组是String[] musics = new String[] { "Island", "Ocean", "Pretty", "Sun" };
即musics[0]="Island" musics[1]="Ocean" musics[2]="Pretty" musics[3]="Sun"(数组长度为4,而下标是从0开始的,所以数组中最后一个元素可以表示为musics[musics.length-1])
这里的newMusics是从数组的最后一个元素也就是newMusics[newMusics.length-1]开始循环,把元素从后往前放入newMusics数组中。以为之前定义了int loc=0;
所以最后一个元素的赋值语句为newMusics[loc]=music(即newMusics[0]=music,music=input.nextLine())。
不知道我解释的,你听没听明白。
如果还有问题请追问或是百度hi我。
希望我的解答对你有所帮助。
关于歌曲java和歌曲jambalaya的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。
