public void ToggleDownload(Activity activity, string name, android.Net.Uri uri, string extension)
        {
            if (IsDownloaded(uri))
            {
                DownloadAction removeAction =
                    GetDownloadHelper(uri, extension).GetRemoveAction(Utils.GetUtf8Bytes(name));

                StartServiceWithAction(removeAction);
            }
            else
            {
                StartDownloadDialogHelper helper = new StartDownloadDialogHelper(activity, GetDownloadHelper(uri, extension), this, name);
                helper.Prepare();
            }
        }
            public void OnClick(IDialogInterface dialog, int which)
            {
                Java.Util.ArrayList selectedTrackKeys = new Java.Util.ArrayList();
                for (int i = 0; i < representationList.ChildCount; i++)
                {
                    if (representationList.IsItemChecked(i))
                    {
                        selectedTrackKeys.Add(trackKeys[i]);
                    }
                }
                if (!selectedTrackKeys.IsEmpty || trackKeys.Count == 0)
                {
                    // We have selected keys, or we're dealing with single stream content.
                    DownloadAction downloadAction =
                        downloadHelper.GetDownloadAction(Utils.GetUtf8Bytes(name), selectedTrackKeys);

                    downloadTracker.StartDownload(downloadAction);
                }
            }
        private DownloadHelper GetDownloadHelper(android.Net.Uri uri, string extension)
        {
            int type = Utils.InferContentType(uri, extension);

            switch (type)
            {
            case C.TypeDash:
                return(new DashDownloadHelper(uri, dataSourceFactory));

            case C.TypeSs:
                return(new SsDownloadHelper(uri, dataSourceFactory));

            case C.TypeHls:
                return(new HlsDownloadHelper(uri, dataSourceFactory));

            case C.TypeOther:
                return(new ProgressiveDownloadHelper(uri));

            default:
                throw new IllegalStateException("Unsupported type: " + type);
            }
        }
 public override void OnCreate()
 {
     base.OnCreate();
     userAgent = Utils.GetUserAgent(this, "ExoPlayerDemo");
 }