정확하게 서버에서 .mp3 음악 파일을 다운로드 할 수있는 앱을 만들려고합니다.이 Android 개발 필드에서 신참으로 어떤 도움을 주시면 감사하겠습니다. 너희들에게서. 시작해야 할 것이 있습니다. 유용한 리소스를 얻을 수있는 링크를 제공 해주시면 정말 고맙겠습니다. 감사android의 서버에서 mp3 파일 다운로드
답변
당신이이 방법 ::
try {
MediaPlayer player = new MediaPlayer();
player.setAudioStreamType(AudioManager.STREAM_MUSIC);
player.setDataSource("http://xty/MRESC/images/test/xy.mp3"
);
player.prepare();
player.star();
} catch (Exception e) {
// TODO: handle exception
}
매니페스트 권한을 수행 할 수 있습니다 어떤 URL에서 .MP3 파일을 재생하려면
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
다음을 따르십시오 nik이 제안한 코드.
하지만 다음이 코드
private class DownloadFile extends AsyncTask<String, Integer, String>{
@Override
protected String doInBackground(String... urlParams) {
int count;
try {
URL url = new URL("url of your .mp3 file");
URLConnection conexion = url.openConnection();
conexion.connect();
// this will be useful so that you can show a tipical 0-100% progress bar
int lenghtOfFile = conexion.getContentLength();
// downlod the file
InputStream input = new BufferedInputStream(url.openStream());
OutputStream output = new FileOutputStream("/sdcard/somewhere/nameofthefile.mp3");
byte data[] = new byte[1024];
long total = 0;
while ((count = input.read(data)) != -1) {
total += count;
// publishing the progress....
publishProgress((int)(total*100/lenghtOfFile));
output.write(data, 0, count);
}
output.flush();
output.close();
input.close();
} catch (Exception e) {}
return null;
}
편집에 따라 파일 서버를 형성하고 SDCARD 또는 내부 저장 장치에있는 모든 장소에 보관 다운로드하려면 : 매니페스트 권한 :
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
고맙습니다. 그러나 여전히 동적으로 입력하는 방법을 모르겠으므로 여전히 문제가 있습니다. 사용자가 링크를 복사하여 붙여 넣으면 텍스트 상자가 있으면 해당 사이트에서 파일 다운로드가 시작됩니다. – clayforbrick
@clayforbrick - 사용자가 복사 - 편집 텍스트 상자에 링크를 붙여 넣으면 해당 편집 텍스트를 가져 와서 다운로드 파일 URL에 전달하십시오. url = 새 URL ("다운로드하려는 .mp3 파일의 URL")); 파일을 저장하는 경우 OutputStream output = new FileOutputStream ("/ sdcard/somewhere/nameofthefile saving file.mp3"); – user370305
그리고 이것이 맞다면이 대답을 수락하십시오. 감사합니다 :-) – user370305
- 1. Android에서 java로 mp3 파일 다운로드
- 2. FTP 서버에서 모든 파일 다운로드
- 3. MP3 파일 (스트리밍 및 다운로드)의 점진적 다운로드 - iPhone SDK
- 4. url에서 mp3 다운로드, PHP
- 5. HTTP 응답에서 .MP3 다운로드
- 6. Android의 서버에서 비디오에 액세스
- 7. cherrypy에서 mp3 파일 제공
- 8. 웹 서버에서 두 개 이상의 파일 다운로드
- 9. Kohana 3 다른 서버에서 파일 다운로드
- 10. 서블릿을 사용하여 서버에서 Excel 파일 다운로드
- 11. SFTP 서버에서 다운로드 한 파일 압축하기
- 12. Sharepoint 서버에서 XML BDC 파일 다운로드
- 13. 서버에서 데이터 다운로드
- 14. 파일 다운로드, urllib2가
- 15. 다운로드 한 mp3 파일을 재생하는 방법은 무엇입니까?
- 16. html의 mp3 파일
- 17. Android의 BroadcastReceiver에서 MP3 재생 작업 수신
- 18. 아마존 AWS S3에서 스트림 대신 MP3 파일 다운로드 강제로
- 19. (Android) 앱 (콘텐츠가 지원되지 않음)을 사용하여 MP3 파일 다운로드
- 20. iphone 응용 프로그램으로 URL에서 mp3 파일 다운로드 및 재생
- 21. Quicktime으로 브라우저에서 열지 않고 강제로 MP3 파일 다운로드
- 22. 서버에서 전체 폴더 다운로드
- 23. J2ME Mp3 플레이어 - 루프에서 mp3 파일 재생
- 24. java.net.Socket을 사용하여 http 콘텐츠 (이미지, mp3 파일 및 기타)를 다운로드 할 수 있습니까?
- 25. 서버에서 파일을 다운로드 할 링크를 제공하십시오.
- 26. 파이썬으로 MP3 파일 재생
- 27. BlackBerry에서 mp3 파일 재생
- 28. libsox로 mp3 파일 재생
- 29. MP3 파일 수정
- 30. mp3 파일 형식
을 Thanx nik..i는 mp3 파일을 다운로드하고 코드는 플레이어 용입니다. – clayforbrick
당신의 코드가 작동하는 동안, OP는 다운로드를 요청했고 코드는 – Jimmar