【发布时间】:2017-07-06 11:27:56
【问题描述】:
我正在尝试从服务器下载 mp3 文件。 我成功制作了,可以播放文件,但是没有缩略图和文件信息,例如艺术家和专辑名称。
当我直接从 chrome 下载文件时,我上面提到的信息确实会被下载。 任何想法如何让它工作?
这是我的代码:
URL url = new URL(urlDwn+urlVid);
HttpURLConnection connection =(HttpURLConnection) url.openConnection();
connection.connect();
//file length
int lengthOfFile = connection.getContentLength();
//intput - read file
InputStream inputStream = new BufferedInputStream(url.openStream(), 8192);
//output - write file
if(true) {
System.out.println("Downloading");
OutputStream outputStream = new FileOutputStream(root+"/"+fileName);
System.out.println(root+"/"+fileName);
byte data[] = new byte[1024];
long total = 0;
while ((count = inputStream.read(data)) != -1) {
total += count;
//progress
publishProgress((int) ((total * 100) / lengthOfFile));
//writing to file
outputStream.write(data,0, count);
}
outputStream.flush();
outputStream.close();
inputStream.close();
【问题讨论】:
-
可能是您检索缩略图和信息的方式有问题?
-
如何找回?
-
当您通过 chrome 下载它时,您确实会以某种方式检索它。
-
但我不想为此使用 chrome。我将数据写入我创建的文件,并且音频效果很好。但我不明白为什么文件的拇指和信息不起作用。
-
他们到底在哪里不工作?
标签: java android android-asynctask download mp3