com.xunlei.downloadlib.parameter.MagnetTaskParam Java Examples

The following examples show how to use com.xunlei.downloadlib.parameter.MagnetTaskParam. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XLTaskHelper.java    From BtPlayer with Apache License 2.0 6 votes vote down vote up
/**
 * 添加磁力链任务
 * @param url 磁力链接 magnet:? 开头
 * @param savePath
 * @param fileName
 * @return
 * @throws Exception
 */
public synchronized long addMagentTask(final String url,final String savePath,String fileName) throws Exception {
    if (url.startsWith("magnet:?")) {
        if(TextUtils.isEmpty(fileName)) {
            final GetFileName getFileName = new GetFileName();
            XLDownloadManager.getInstance().getFileNameFromUrl(url, getFileName);
            fileName = getFileName.getFileName();
        }
        MagnetTaskParam magnetTaskParam = new MagnetTaskParam();
        magnetTaskParam.setFileName(fileName);
        magnetTaskParam.setFilePath(savePath);
        magnetTaskParam.setUrl(url);
        final GetTaskId getTaskId = new GetTaskId();
        XLDownloadManager.getInstance().createBtMagnetTask(magnetTaskParam, getTaskId);

        XLDownloadManager.getInstance().setTaskLxState(getTaskId.getTaskId(), 0, 1);
        XLDownloadManager.getInstance().startDcdn(getTaskId.getTaskId(), 0, "", "", "");
        XLDownloadManager.getInstance().startTask(getTaskId.getTaskId(), false);
        return getTaskId.getTaskId();
    } else {
        throw new Exception("url illegal.");
    }
}
 
Example #2
Source File: XLTaskHelper.java    From AndroidDownload with Apache License 2.0 6 votes vote down vote up
/**
 * 添加磁力链任务
 * @param url 磁力链接 magnet:? 开头
 * @param savePath
 * @param fileName
 * @return
 * @throws Exception
 */
public synchronized long addMagentTask(final String url,final String savePath,String fileName) throws Exception {
     if (url.startsWith("magnet:?")) {
        if(TextUtils.isEmpty(fileName)) {
            final GetFileName getFileName = new GetFileName();
            XLDownloadManager.getInstance().getFileNameFromUrl(url, getFileName);
            fileName = getFileName.getFileName();
        }
        MagnetTaskParam magnetTaskParam = new MagnetTaskParam();
        magnetTaskParam.setFileName(fileName);
        magnetTaskParam.setFilePath(savePath);
        magnetTaskParam.setUrl(url);
        final GetTaskId getTaskId = new GetTaskId();
        XLDownloadManager.getInstance().createBtMagnetTask(magnetTaskParam, getTaskId);

        XLDownloadManager.getInstance().setTaskLxState(getTaskId.getTaskId(), 0, 1);
        XLDownloadManager.getInstance().startDcdn(getTaskId.getTaskId(), 0, "", "", "");
        XLDownloadManager.getInstance().startTask(getTaskId.getTaskId(), false);
        return getTaskId.getTaskId();
    } else {
        throw new Exception("url illegal.");
    }
}
 
Example #3
Source File: XLTaskHelper.java    From MiniThunder with Apache License 2.0 6 votes vote down vote up
/**
 * 添加磁力链任务
 * @param url 磁力链接 magnet:? 开头
 * @param savePath
 * @param fileName
 * @return
 * @throws Exception
 */
public synchronized long addMagentTask(final String url,final String savePath,String fileName) throws Exception {
    if (url.startsWith("magnet:?")) {
        if(TextUtils.isEmpty(fileName)) {
            final GetFileName getFileName = new GetFileName();
            XLDownloadManager.getInstance().getFileNameFromUrl(url, getFileName);
            fileName = getFileName.getFileName();
        }
        MagnetTaskParam magnetTaskParam = new MagnetTaskParam();
        magnetTaskParam.setFileName(fileName);
        magnetTaskParam.setFilePath(savePath);
        magnetTaskParam.setUrl(url);
        final GetTaskId getTaskId = new GetTaskId();
        XLDownloadManager.getInstance().createBtMagnetTask(magnetTaskParam, getTaskId);

        XLDownloadManager.getInstance().setTaskLxState(getTaskId.getTaskId(), 0, 1);
        XLDownloadManager.getInstance().startDcdn(getTaskId.getTaskId(), 0, "", "", "");
        XLDownloadManager.getInstance().startTask(getTaskId.getTaskId(), false);
        return getTaskId.getTaskId();
    } else {
        throw new Exception("url illegal.");
    }
}
 
Example #4
Source File: XLTaskHelper.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 添加磁力链任务
 * @param url 磁力链接 magnet:? 开头
 * @param savePath
 * @param fileName
 * @return
 * @throws Exception
 */
public synchronized long addMagentTask(final String url,final String savePath,String fileName) throws Exception {
    if (url.startsWith("magnet:?")) {
        XLDownloadManager instance = XLDownloadManager.getInstance();
        if(TextUtils.isEmpty(fileName)) {
            final GetFileName getFileName = new GetFileName();
            instance.getFileNameFromUrl(url, getFileName);
            fileName = getFileName.getFileName();
        }
        MagnetTaskParam magnetTaskParam = new MagnetTaskParam();
        magnetTaskParam.setFileName(fileName);
        magnetTaskParam.setFilePath(savePath);
        magnetTaskParam.setUrl(url);
        final GetTaskId getTaskId = new GetTaskId();
        int r1 = XLDownloadManager.getInstance().createBtMagnetTask(magnetTaskParam, getTaskId);
        if (r1 != 9000) {
            Log.e(TAG,"create bt_task failed: " + XLDownloadManager.getInstance().getErrorCodeMsg(r1));
        }

        //instance.setDownloadTaskOrigin(getTaskId.getTaskId(), "out_app/out_app_paste");
        //instance.setOriginUserAgent(getTaskId.getTaskId(), "AndroidDownloadManager/5.41.2.4980 (Linux; U; Android 4.4.4; Build/KTU84Q)");
        instance.setTaskLxState(getTaskId.getTaskId(), 0, 1);
        instance.startDcdn(getTaskId.getTaskId(), 0, "", "611", "");
        r1 = instance.startTask(getTaskId.getTaskId(), false);
        if (r1 != 9000) {
            Log.e(TAG,"start bt_task failed: " + XLDownloadManager.getInstance().getErrorCodeMsg(r1));
        }
        return getTaskId.getTaskId();
    } else {
        throw new Exception("url illegal.");
    }
}
 
Example #5
Source File: XLDownloadManager.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public int createBtMagnetTask(MagnetTaskParam magnetTaskParam, GetTaskId getTaskId) {
    int i = 9900;
    if (!(magnetTaskParam == null || getTaskId == null || !magnetTaskParam.checkMemberVar())) {
        increRefCount();
        if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && this.mLoader != null) {
            i = this.mLoader.createBtMagnetTask(magnetTaskParam.mUrl, magnetTaskParam.mFilePath, magnetTaskParam.mFileName, getTaskId);
        }
        decreRefCount();
    }
    return i;
}
 
Example #6
Source File: XLDownloadManager.java    From BtPlayer with Apache License 2.0 5 votes vote down vote up
public int createBtMagnetTask(MagnetTaskParam magnetTaskParam, GetTaskId getTaskId) {
    int i = 9900;
    if (!(magnetTaskParam == null || getTaskId == null || !magnetTaskParam.checkMemberVar())) {
        increRefCount();
        if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && this.mLoader != null) {
            i = this.mLoader.createBtMagnetTask(magnetTaskParam.mUrl, magnetTaskParam.mFilePath, magnetTaskParam.mFileName, getTaskId);
        }
        decreRefCount();
    }
    return i;
}
 
Example #7
Source File: XLDownloadManager.java    From AndroidDownload with Apache License 2.0 5 votes vote down vote up
public int createBtMagnetTask(MagnetTaskParam magnetTaskParam, GetTaskId getTaskId) {
    int i = 9900;
    if (!(magnetTaskParam == null || getTaskId == null || !magnetTaskParam.checkMemberVar())) {
        increRefCount();
        if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && this.mLoader != null) {
            i = this.mLoader.createBtMagnetTask(magnetTaskParam.mUrl, magnetTaskParam.mFilePath, magnetTaskParam.mFileName, getTaskId);
        }
        decreRefCount();
    }
    return i;
}
 
Example #8
Source File: XLDownloadManager.java    From MiniThunder with Apache License 2.0 5 votes vote down vote up
public int createBtMagnetTask(MagnetTaskParam magnetTaskParam, GetTaskId getTaskId) {
    int i = 9900;
    if (!(magnetTaskParam == null || getTaskId == null || !magnetTaskParam.checkMemberVar())) {
        increRefCount();
        if (mDownloadManagerState == XLManagerStatus.MANAGER_RUNNING && this.mLoader != null) {
            i = this.mLoader.createBtMagnetTask(magnetTaskParam.mUrl, magnetTaskParam.mFilePath, magnetTaskParam.mFileName, getTaskId);
        }
        decreRefCount();
    }
    return i;
}