Class DownloadServiceBinder

  • All Implemented Interfaces:
    IBinder

    public class DownloadServiceBinder
    extends Binder
    The binder providing access to DownloadService.

    Bind to DownloadService as follows:

    
     DownloadServiceBinder downloadServiceBinder;
     ServiceConnection downloadServiceConnection = new ServiceConnection() {
            public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
                    downloadServiceBinder = (DownloadServiceBinder) iBinder;
            }
            public void onServiceDisconnected(ComponentName componentName) {
                    downloadServiceBinder = null;
            }
     }
    
     String downloadId = "ID";
     File moviesFolder = getExternalFilesDir(Environment.DIRECTORY_MOVIES);
     File target = new File(moviesFolder, "Downloads/" + downloadId);
    
     Bundle bundle = new Bundle();
     bundle.putString(SdkConsts.INTENT_URL, "MANIFEST_URL");
     bundle.putString(SdkConsts.INTENT_DOWNLOAD_ID, downloadId);
     bundle.putString(SdkConsts.INTENT_DOWNLOAD_FOLDER, target.getAbsolutePath());
    
     downloadServiceBinder.prepareDownload(context, bundle, new Downloader.ModelReadyCallback() {
            public void onError(@NonNull Exception e) {
                    Log.e(TAG, "Error while preparing download: " + e.getMessage(), e);
            }
            public void onModelAvailable(@NonNull Download download) {
                    // initiate selection here of video quality, audio and subtitle tracks
                    // either automatically or manually
            }
     });
     
    Since:
    3.2.0
Parameters:
context - The context
bundle - The bundle
callback - The caller callback or null