概述
我自己修复它,我使用的是android,流URL也是下载URL.流URL也是要下载的下载URL,但不会影响下载次数.你可以这样尝试
String file_url = "https://api.soundcloud.com/tracks/93216523/stream?client_id=4346c8125f4f5c40ad666bacd8e96498";
将此网址传递给asyntack并管理您的下载,您可以像这样传递它
new DownloadFileFromURL().execute(file_url);
这是使用asyntask的DownloadFileFromUR类
class DownloadFileFromURL extends AsyncTask {
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected String doInBackground(String... f_url) {
URL u = null;
InputStream is = null;
try {
u = new URL(f_url[0]);
is = u.openStream();
HttpURLConnection huc = (HttpURLConnection)u.openConnection();//to know the size of video
int size = huc.getContentLength();
if(huc != null){
String fileName = "FILE2.mp3";
String storagePath = Environment.getExternalStorageDirectory().toString();
File f = new File(storagePath,fileName);
FileOutputStream fos = new FileOutputStream(f);
byte[] buffer = new byte[1024];
long total = 0;
int len1 = 0;
if(is != null){
while ((len1 = is.read(buffer)) > 0) {
total+=len1;
publishProgress((int)((total*100)/size));
fos.write(buffer,0, len1);
}
}
if(fos != null){
fos.close();
}
}
}catch (MalformedURLException mue) {
mue.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
try {
if(is != null){
is.close();
}
}catch (IOException ioe) {
// just going to ignore this one
}
}
return "";
}
@Override
protected void onPostExecute(String file_url) {
}
}
最后
以上就是朴素月饼为你收集整理的android 获取mp3专辑id,android-如何通过使用音频文件ID获取soundclou...的全部内容,希望文章能够帮你解决android 获取mp3专辑id,android-如何通过使用音频文件ID获取soundclou...所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复