Esempio n. 1
0
  /*
  	public static File getPrimaryFile(Download d) {
  		DiskManagerFileInfo info = getPrimaryFileInfo(d);

  		if ( info == null ){
  			return( null );
  		}else{
  			return( info.getFile( true ));
  		}
  	}

  	public static int getPrimaryFileIndex(DownloadManager dm ){
  		return( getPrimaryFileIndex( PluginCoreUtils.wrap( dm )));
  	}

  	public static int getPrimaryFileIndex(Download d) {
  		DiskManagerFileInfo info = getPrimaryFileInfo(d);

  		if ( info == null ){
  			return( -1 );
  		}else{
  			return( info.getIndex());
  		}
  	}

  	public static DiskManagerFileInfo getPrimaryFileInfo(Download d) {
  		long size = d.getTorrent().getSize();
  		DiskManagerFileInfo[] infos = d.getDiskManagerFileInfo();
  		for(int i = 0; i < infos.length ; i++) {
  			DiskManagerFileInfo info = infos[i];
  			if ( info.isSkipped() || info.isDeleted()){
  				continue;
  			}
  			if( info.getLength() > (long)fileSizeThreshold * size / 100l) {
  				return info;
  			}
  		}
  		return null;
  	}
  */
  public static boolean isExternallyPlayable(Download d, int file_index, boolean complete_only) {

    int primary_file_index = -1;

    if (file_index == -1) {

      DownloadManager dm = PluginCoreUtils.unwrap(d);

      if (dm == null) {

        return (false);
      }

      DiskManagerFileInfo file = null;
      try {
        file = PluginCoreUtils.wrap(dm.getDownloadState().getPrimaryFile());
      } catch (DownloadException e) {
        return false;
      }

      if (file == null) {

        return (false);
      }

      if (file.getDownloaded() != file.getLength()) {

        if (complete_only || getMediaServerContentURL(file) == null) {

          return (false);
        }
      }

      primary_file_index = file.getIndex();

    } else {

      DiskManagerFileInfo file = d.getDiskManagerFileInfo(file_index);

      if (file.getDownloaded() != file.getLength()) {

        if (complete_only || getMediaServerContentURL(file) == null) {

          return (false);
        }
      }

      primary_file_index = file_index;
    }

    if (primary_file_index == -1) {

      return false;
    }

    return (isExternallyPlayable(d.getDiskManagerFileInfo()[primary_file_index]));
  }
Esempio n. 2
0
  /** @deprecated */
  public static int getPrimaryFileIndex(Download dl) {
    EnhancedDownloadManager edm =
        DownloadManagerEnhancer.getSingleton().getEnhancedDownload(PluginCoreUtils.unwrap(dl));

    if (edm == null) {

      return -1;
    }

    return edm.getPrimaryFileIndex();
  }