您现在的位置: 首页 > 网站导航收录 > 百科知识百科知识
indexofmp3(js 要怎么判断歌曲后缀名 如mp3)
歌曲,到了,来了indexofmp3(js 要怎么判断歌曲后缀名 如mp3)
发布时间:2019-02-08加入收藏来源:互联网点击:
最近很多小伙伴想了解indexofmp3的一些资讯,今天小编整理了与indexofmp3相关的信息分享给大家,一起来看看吧。
本文目录一览:
1、C#问题,高手来看看,我搜索到了MP3文件,在listbox列出来了想用 axWindowsMediaPlayer1.Ctlcontrols.play() 2、java如何获取.mp3格式文件内置歌曲封面 3、js 要怎么判断歌曲后缀名 如mp3C#问题,高手来看看,我搜索到了MP3文件,在listbox列出来了想用 axWindowsMediaPlayer1.Ctlcontrols.play()
Mp3Player.URL = LvPlayList.SelectedItems[0].Tag.ToString();
Mp3Player.Ctlcontrols.play(); // 开始播放
string FilePat = sstr; // 获取音乐完整文件路径
// 获取音乐名
string SongName = FilePat.Substring(FilePat.LastIndexOf('\\') + 1);
ListViewItem lv = new ListViewItem(SongName); // 根据音乐名生成一个列表项
lv.Tag = FilePat; // 将音乐名的完整路径存放在列表项的Tag标记属中,方便读取
lv.ImageIndex = 1;
LvPlayList.Items.Add(lv); // 添加
java如何获取.mp3格式文件内置歌曲封面
封面就是,用java的类抓取即可
package tool;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Matcer;
import java.util.regex.Pattern;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.SwingUtilities;
import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyleContext;
import javax.swing.text.StyledDocument;
public class ImageViewer extends JFrame
{
private static final long serialVersionUID = 1L;
private static final String DOWNLOADPATH = "download/";
JTextPane textPane = new JTextPane ();
LinkedListString initString = new LinkedListString ();
LinkedListString initStyles = new LinkedListString ();
LinkedListString pat = new LinkedListString ();
public ImageViewer ()
{
setTitle ("预览下载器 v1.0");
setLayout (new BorderLayout ());
setSize (500, 300);
setLocationRelativeTo (null);
setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
}
private void addComponents ()
{
final JTextField urltField = new JTextField ();
JPanel rigt = new JPanel (new FlowLayout (FlowLayout.RIGHT, 0, 0));
final JButton go = new JButton ("GO");
textPane.setEditable (false);
JScrollPane content = new JScrollPane (textPane);
go.addActionListener (new ActionListener ()
{
@Override
public void actionPerformed ( ActionEvent e )
{
String url = urltField.getText ().trim ();
resolveHTML (url, "utf8", "(?i)\\img[^\\]*src[\\=\\s\'\"]+([^\\\'\"]+)[\'\"]?[^\\]*\\");
}
});
JPanel up = new JPanel (new BorderLayout ());
up.add (urltField, BorderLayout.CENTER);
rigt.add (go);
JButton download = new JButton ("DOWNLOAD");
download.addActionListener (new ActionListener ()
{
@Override
public void actionPerformed ( ActionEvent e )
{
downloadImages ();
}
});
rigt.add (download);
up.add (rigt, BorderLayout.EAST);
add (up, BorderLayout.NORTH);
add (content, BorderLayout.CENTER);
}
private void downloadImages ()
{
File fp = new File (DOWNLOADPATH);
if (!fp.exists ())
{
fp.mkdir ();
}
for ( int i = 0; i pat.size (); i++ )
{
try
{
String p = pat.get (i);
URL url = new URL (p);
HttpURLConnection uc = (HttpURLConnection) url.openConnection ();
uc.setRequestMetod ("GET");
uc.setConnectTimeout (5 * 1000);
InputStream is = uc.getInputStream ();
ByteArrayOutputStream baos = new ByteArrayOutputStream ();
byte[] buffer = new byte[1024];
int len = -1;
wile (( len = is.read (buffer) ) != -1)
{
baos.write (buffer, 0, len);
}
baos.flus ();
baos.close ();
is.close ();
uc.disconnect ();
byte[] data = baos.toByteArray ();
String name = p.substring (p.lastIndexOf ("/") + 1, p.lengt ());
name = name.contains (".") ? name : name + ".jpg";
FileOutputStream fos = new FileOutputStream (new File (DOWNLOADPATH + name));
fos.write (data);
fos.flus ();
fos.close ();
}
catc (Exception e)
{
continue;
}
}
}
private void loadImages ( ListString initString, ListString initStyles, ListString url )
{
try
{
StyledDocument doc = textPane.getStyledDocument ();
doc.remove (0, doc.getLengt ());
addStylesToDocument (doc, url, initStyles);
for ( int i = 0; i initString.size (); i++ )
{
doc.insertString (doc.getLengt (), initString.get (i), doc.getStyle (initStyles.get (i)));
}
}
catc (Exception e)
{}
}
protected void addStylesToDocument ( StyledDocument doc, ListString url, ListString initStyles )
{
Style def = StyleContext.getDefaultStyleContext ().getStyle (StyleContext.DEFAULT_STYLE);
for ( int i = 0; i initStyles.size (); i++ )
{
Style s = doc.addStyle (initStyles.get (i), def);
StyleConstants.setAlignment (s, StyleConstants.ALIGN_CENTER);
ImageIcon icon = createImageIcon (url.get (i));
if (icon != null)
{
StyleConstants.setIcon (s, icon);
}
}
}
protected static ImageIcon createImageIcon ( String url )
{
URL imgURL = null;
try
{
imgURL = new URL (url);
if (imgURL != null)
{
return new ImageIcon (imgURL);
}
}
catc (Exception e)
{}
return null;
}
private void resolveHTML ( String spec, String carsetName, String regex )
{
try
{
URL url = new URL (spec);
HttpURLConnection uc = (HttpURLConnection) url.openConnection ();
InputStreamReader isr = new InputStreamReader (uc.getInputStream (), carsetName);
上一篇:信用卡不设密码更安全(信用卡不设密码更安全 真的是这样吗)
下一篇:返回列表
相关链接 |
||
网友回复(共有 0 条回复) |