@Override
  public void onDownloadComplete(DownloadItem item) {
    LOGD("download", "completed");
    String localPath = getLocalPath(item.getItemId());
    VideoItem videoItem = findItemByMediaId(item.getItemId());
    if (localPath != null && videoItem != null) {
      LocalAssetsManager.registerAsset(
          mContext,
          videoItem.config,
          videoItem.flavorId,
          localPath,
          new LocalAssetsManager.AssetRegistrationListener() {
            @Override
            public void onRegistered(String assetPath) {
              LOGD("download", "Register successful");
            }

            @Override
            public void onFailed(String assetPath, Exception error) {
              LOGD("download", "Register failed " + error.getMessage());
            }
          });
    }
    DownloadItemView view = getView(getItemPositionByMediaId(item.getItemId()));
    if (view != null) {
      view.bind(item);
    }
  }
 @Override
 public void onDownloadClick(int itemId) {
   DownloadItem item = getItem(itemId).findDownloadItem();
   if (item != null && item.getState() != DownloadState.COMPLETED) {
     item.loadMetadata();
   }
 }
 @Override
 public void onDownloadStop(DownloadItem item) {
   LOGD("onDownloadStop", "");
   DownloadItemView view = getView(getItemPositionByMediaId(item.getItemId()));
   if (view != null) {
     view.bind(item);
   }
 }
 @Override
 public void onProgressChange(DownloadItem item, long downloadedBytes) {
   LOGD("onProgressChange", "downloaded " + downloadedBytes);
   DownloadItemView view = getView(getItemPositionByMediaId(item.getItemId()));
   if (view != null) {
     view.bind(item);
   }
 }
  @Override
  public void onDownloadMetadata(DownloadItem item, Exception error) {
    LOGD("onDownloadMetadata", "");

    DownloadItem.TrackSelector trackSelector = item.getTrackSelector();
    if (trackSelector != null) {
      List<DownloadItem.Track> downloadedVideoTracks =
          trackSelector.getDownloadedTracks(DownloadItem.TrackType.VIDEO);

      List<DownloadItem.Track> availableTracks =
          trackSelector.getAvailableTracks(DownloadItem.TrackType.AUDIO);
      if (availableTracks.size() > 0) {
        trackSelector.setSelectedTracks(DownloadItem.TrackType.AUDIO, availableTracks);
      }
      try {
        trackSelector.apply();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }

    item.startDownload();
  }