-6

비디오 URL을 다운로드하려면 타사 라이브러리를 찾고 있습니다.안드로이드에서 비디오를 다운로드 할 타사 라이브러리가 있습니까

현재 수동으로 비디오를 다운로드하여 사용 중입니다. 당신이 알고있는 경우

은 나에게 당신이 그것을 참조 할 수 있습니다 sdcard에 폴더에 비디오 다운로드 한 AsyncTask를 사용 buid.gradle

+0

당신이 URL에서 비디오를 다운로드합니다 AsyncTask를 사용. –

+0

@ Rao의 [this] (https://github.com/MindorksOpenSource/PRDownloader) 라이브러리 –

+0

여기 도서관을 요청해서는 안된다는 사실을 알고 계십니까? –

답변

2

를 사용하여 알려 주시기 :

public class DounloadVideoRequestTask extends AsyncTask<String, Integer, Object> { 

public static final String TAG = "DounloadVideoRequestTask"; 
public Context mContext; 
private AsyncCallListener mAsyncCallListener; 
private String mErrorMessage; 
private boolean mIsError = false; 

public DounloadVideoRequestTask(Context mContext) { 
    this.mContext = mContext; 
} 

@Override 
protected void onPreExecute() { 
    super.onPreExecute(); 
} 

@Override 
protected Object doInBackground(String... params) { 
    return storeImage(params[0], params[1], params[2]); 
} 

@Override 
protected void onPostExecute(Object result) { 
    super.onPostExecute(result); 
    if (mAsyncCallListener != null) { 
     if (mIsError) { 
      Logger.e("", "In Asnyc call->errorMessage:" + mErrorMessage); 
      mAsyncCallListener.onErrorReceived(mErrorMessage); 
     } else { 
      mAsyncCallListener.onResponseReceived(result); 
     } 
    } 
} 

public void setAsyncCallListener(AsyncCallListener listener) { 
    this.mAsyncCallListener = listener; 
} 

private Object storeImage(String media, String media_type, String image_name) { 
    int count; 
    try { 
     URL url = new URL(media); 
     URLConnection conexion = url.openConnection(); 
     conexion.connect(); 
     int lenghtOfFile = conexion.getContentLength(); 
     String PATH = Environment.getExternalStorageDirectory() + "/Media/"; 
     File folder = new File(PATH); 
     if (!folder.exists()) { 
      folder.mkdirs();//If there is no folder it will be created. 
     } 

     File myFile; 
     String PATH2 = ""; 
      PATH2 = PATH + "/Video/"; 
      myFile = new File(PATH2, image_name); 

     if (!myFile.exists()) { 
      myFile.getParentFile().mkdirs(); 
     } 

     InputStream input = new BufferedInputStream(url.openStream()); 
     OutputStream output = new FileOutputStream(myFile); 
     byte data[] = new byte[1024]; 
     long total = 0; 
     while ((count = input.read(data)) != -1) { 
      total += count; 
      publishProgress((int) (total * 100/lenghtOfFile)); 
      output.write(data, 0, count); 
     } 
     output.flush(); 
     output.close(); 
     input.close(); 
    } catch (Exception e) { 
     e.printStackTrace(); 
     Logger.e(TAG, "Dounload Failed Exception : " + image_name); 
    } 

    return null; 
    } 
} 
0

당신은 사용할 수 AsyncTask 또는 안드로이드 기본 DownloadManager. DownloadManager이 가장 좋습니다. Downloadmanager하여 - 당신이 라이브러리에 대한 질문으로

Download_Uri = Uri.parse("http://exaple.com/cropped-web_hi_res_512.mp4"); 

       DownloadManager.Request request = new DownloadManager.Request(Download_Uri); 
       request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE); 
       request.setAllowedOverRoaming(false); 
       request.setTitle("GadgetSaint Downloading " + "Sample" + ".mp4"); 
       request.setDescription("Downloading " + "Sample" + ".mp4"); 
       request.setVisibleInDownloadsUi(true); 
       request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "/videoDir/" + "/" + "Sample" + ".mp4"); 


       refid = downloadManager.enqueue(request); 

, 나는 몇 가지를 참조 할 수 있습니다. 이러한 확인 -

1) Android arsenal
2) PRDownloader
3) AndroidNetwroking Library

+1

이 링크가 질문에 대답 할 수 있지만 여기에 답변의 핵심 부분을 포함하고 참조 용 링크를 제공하는 것이 좋습니다. 링크 된 페이지가 변경되면 링크 전용 답변이 유효하지 않게 될 수 있습니다. - [리뷰에서] (리뷰/저품절 포스트/18168089) –

+0

그는 비디오를 다운로드 할 라이브러리가 있는지 물었습니다. 그 이유는 방금 라이브러리 이름으로 링크를 추가했기 때문입니다. –

+0

라이브러리에 대한 질문은 Stack Overflow에서 주제와 관련이 없으므로 어쨌든 질문에 대답해서는 안됩니다. 대부분의 경우 링크 만 응답은 낮은 품질로 간주됩니다. 주제를 벗어난 질문에 대해 이렇게 대답하는 것은 갑자기 그 일을 올바르게하지는 못합니다. – Ivar

관련 문제