-6

私はビデオURLをダウンロードするサードパーティのライブラリを探しています。アンドロイドでビデオをダウンロードするサードパーティのライブラリはありますか?

現在、手動でビデオをダウンロードして使用しています。

あなたはどんな私がasynctaskを使用しbuid.gradle

+0

あなたはURLから動画をダウンロードしますasynctaskを使用します。 –

+0

@ Rao's [this](https://github.com/MindorksOpenSource/PRDownloader)ライブラリ –

+0

ここで図書館を尋ねるべきではないことを知っていますか? –

答えて

2

を使用して知らせてを知っていれば、私はあなたがそれを参照することができますSDカードのフォルダ内の動画をダウンロードした:

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やAndroidのデフォルトを使用することができますDownloadManagerDownloadManagerが最適です。 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

ライブラリーの依頼はスタックオーバーフローに関する話題になっていますので、とにかくそれらの質問に答えるべきではありません。ほとんどの場合、リンクのみの回答は低品質とみなされます。話題以外の質問でこのように答えても、突然正しいことにはなりません。 – Ivar

関連する問題