private IMediaSource GetSource(string url)
        {
            var uri              = Android.Net.Uri.Parse(url);
            var factory          = URLUtil.IsHttpUrl(url) || URLUtil.IsHttpsUrl(url) ? GetHttpFactory() : new FileDataSourceFactory();
            var extractorFactory = new DefaultExtractorsFactory();

            return(new ExtractorMediaSource(uri
                                            , factory
                                            , extractorFactory, null, this));
        }
Exemple #2
0
        private async void PlayEdit(Edit edit)
        {
            var videofile = edit.shortlink;

            shareedit = edit;

            Bootlegger.BootleggerClient.LogUserAction("Preview",
                                                      new KeyValuePair <string, string>("editid", edit.id));

            //AndHUD.Shared.Show(this, "Loading...", -1, MaskType.Black, null, null, true);
            //FindViewById<EditVideoView>(Resource.Id.videoplayer).ClearVideoSource();
            //FindViewById<ImageButton>(Resource.Id.sharebtn).Visibility = ViewStates.Visible;
            //get video url:
            try {
                //set other fields:
                FindViewById <TextView>(Resource.Id.metadata).Text = edit.title;
                FindViewById <TextView>(Resource.Id.timemeta).Text = edit.createdAt.LocalizeFormat("ha E d MMM yy");
                if (string.IsNullOrEmpty(edit.description))
                {
                    FindViewById <TextView>(Resource.Id.description).Visibility = ViewStates.Gone;
                }
                else
                {
                    FindViewById <TextView>(Resource.Id.description).Text       = edit.description;
                    FindViewById <TextView>(Resource.Id.description).Visibility = ViewStates.Visible;
                }

                string url = await Bootlegger.BootleggerClient.GetEditUrl(edit);


                //DefaultHttpDataSourceFactory httpDataSourceFactory = new DefaultHttpDataSourceFactory("BootleggerPreview");

                ////var ok = new OkHttpClient();
                //int cacheSize = 300 * 1024 * 1024; // 300 MiB
                //Square.OkHttp3.Cache cache = new Square.OkHttp3.Cache(FilesDir, cacheSize);

                var client = new OkHttpClient.Builder()
                             //.Cache((Application as  BootleggerApp).FilesCache)
                             .Build();
                OkHttpDataSourceFactory httpDataSourceFactory = new OkHttpDataSourceFactory(client, "BootleggerPreview");

                var extractorsFactory = new DefaultExtractorsFactory();
                mediaSource = new ExtractorMediaSource(Android.Net.Uri.Parse(url), httpDataSourceFactory, extractorsFactory, null, null);
                _player.Prepare(mediaSource);
            }
            catch (Exception e)
            {
                //adjust to what kind of exception it is:
                LoginFuncs.ShowToast(this, e);
            }
            finally
            {
                //AndHUD.Shared.Dismiss();
            }
        }
        private IMediaSource GetSourceByUrl(string url)
        {
            var bandwithMeter    = new DefaultBandwidthMeter();
            var httpFactory      = new DefaultHttpDataSourceFactory(ExoPlayerUtil.GetUserAgent(this, ApplicationInfo.Name), bandwithMeter);
            var factory          = new HttpSourceFactory(httpFactory, RequestHeaders);
            var extractorFactory = new DefaultExtractorsFactory();
            var uri = Android.Net.Uri.Parse(url);

            return(new ExtractorMediaSource(uri
                                            , factory
                                            , extractorFactory, null, null));
        }
 public override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     SetStyle((int)DialogFragmentStyle.Normal, Resource.Style.ShootDialog);
     webclient = new OkHttpClient.Builder()
                 .Cache((Activity.Application as BootleggerApp).FilesCache)
                 .Build();
     httpDataSourceFactory            = new OkHttpDataSourceFactory(webclient, "BootleggerEditor");
     extractorsFactory                = new DefaultExtractorsFactory();
     _audioPlayer                     = ExoPlayerFactory.NewSimpleInstance(Context, new DefaultTrackSelector());
     _audioPlayer.RenderedFirstFrame += _audioPlayer_RenderedFirstFrame;
 }
Exemple #5
0
        public void SetMediaUrlSource(string url)
        {
            // Produces DataSource instances through which media data is loaded.
            var dataSourceFactory = new DefaultDataSourceFactory(_context, Util.GetUserAgent(_context, "ExoPlayerTest"),
                                                                 _defaultBandwidthMeter);
            // Produces Extractor instances for parsing the media data.
            var extractorsFactory = new DefaultExtractorsFactory();

            // This is the MediaSource representing the media to be played.
            var uri = Android.Net.Uri.Parse(url);

            _videoSource = new ExtractorMediaSource(uri, dataSourceFactory, extractorsFactory, null, null);
        }
 private IMediaSource GetSource(string url)
 {
     var uri = Android.Net.Uri.Parse(url);
     var factory =  URLUtil.IsHttpUrl(url) || URLUtil.IsHttpsUrl(url) ? GetHttpFactory() : new FileDataSourceFactory();
     var extractorFactory = new DefaultExtractorsFactory();
     return new ExtractorMediaSource(uri
         , factory
         , extractorFactory, null, this);
 }
Exemple #7
0
        //private void Preview_Click(object sender, EventArgs e)
        //{
        //    Intent sharingIntent = new Intent(Intent.ActionSend);
        //    sharingIntent.SetType("text/plain");
        //    sharingIntent.PutExtra(Intent.ExtraSubject, shareedit.title);
        //    sharingIntent.PutExtra(Intent.ExtraText, Bootlegger.BootleggerClient.server + "/v/" + shareedit.shortlink);
        //    StartActivity(Intent.CreateChooser(sharingIntent, new Java.Lang.String(Resources.GetString(Resource.String.sharevia))));
        //}

        public async void PlayVideo(MediaItem media)
        {
            Bootlegger.BootleggerClient.LogUserAction("Preview",
                                                      new KeyValuePair <string, string>("mediaid", media.id));

            if (Intent.GetBooleanExtra(Review.INGEST_MODE, false))
            {
                var rv = FindViewById <RecyclerView>(Resource.Id.list);
                rv.SetLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.Horizontal, false));

                var _readonly = Intent.GetBooleanExtra(Review.READ_ONLY, false);

                var chips = new ChipAdapter(this, _readonly);

                //var prev = Resources.GetStringArray(Resource.Array.default_edit_topics).ToList();
                //if (string.IsNullOrEmpty(Bootlegger.BootleggerClient.CurrentEvent.topics))
                //    Bootlegger.BootleggerClient.CurrentEvent.topics = string.Join(",", prev);
                //else
                //prev = Bootlegger.BootleggerClient.CurrentEvent.topics.Split(',').ToList();

                if (_readonly)
                {
                    chips.Update(null, media);
                }
                else
                {
                    chips.Update(Bootlegger.BootleggerClient.CurrentEvent.topics.ToList(), media);
                }

                rv.SetAdapter(chips);
                FindViewById(Resource.Id.videometadata).Visibility = ViewStates.Gone;
            }

            FindViewById <ImageView>(Resource.Id.imageplayer).SetImageDrawable(null);

            try
            {
                FindViewById <TextView>(Resource.Id.metadata).Text = media.meta.shot_ex["name"].ToString() + " at " + media.meta.role_ex["name"].ToString() + " during " + media.meta.phase_ex["name"].ToString();
            }
            catch
            {
                FindViewById <TextView>(Resource.Id.metadata).Text = "";
            }
            try
            {
                FindViewById <TextView>(Resource.Id.timemeta).Text = media.CreatedAt.LocalizeFormat("ha E d MMM yy");
            }
            catch
            {
                FindViewById <TextView>(Resource.Id.timemeta).Text = media.Static_Meta["captured_at"].ToString();
            }


            FindViewById <TextView>(Resource.Id.description).Visibility = ViewStates.Gone;

            switch (media.MediaType)
            {
            case Shot.ShotTypes.VIDEO:
            case Shot.ShotTypes.AUDIO:
                //FindViewById<View>(Resource.Id.videoplayer).Visibility = ViewStates.Visible;
                try
                {
                    //set other fields:
                    string url = await Bootlegger.BootleggerClient.GetVideoUrl(media);

                    if (url.StartsWith("file://"))
                    {
                        DefaultDataSourceFactory httpDataSourceFactory = new DefaultDataSourceFactory(this, "BootleggerPreview");

                        var extractorsFactory = new DefaultExtractorsFactory();
                        mediaSource = new ExtractorMediaSource(Android.Net.Uri.Parse(url), httpDataSourceFactory, extractorsFactory, null, null);
                    }
                    else
                    {
                        var client = new OkHttpClient.Builder()
                                     .Cache((Application as BootleggerApp).FilesCache)
                                     .Build();

                        OkHttpDataSourceFactory httpDataSourceFactory = new OkHttpDataSourceFactory(client, "BootleggerPreview");

                        var extractorsFactory = new DefaultExtractorsFactory();
                        mediaSource = new ExtractorMediaSource(Android.Net.Uri.Parse(url), httpDataSourceFactory, extractorsFactory, null, null);
                    }

                    _player.Prepare(mediaSource);
                }
                catch (Exception e)
                {
                    //Toast.MakeText(this, Resource.String.cannotloadvideo, ToastLength.Short).Show();
                    LoginFuncs.ShowToast(this, e);
                }
                break;

            case Shot.ShotTypes.PHOTO:
                //FindViewById<View>(Resource.Id.videoplayer).Visibility = ViewStates.Gone;
                if (media.Status == MediaItem.MediaStatus.DONE && !string.IsNullOrEmpty(media.path))
                {
                    //string url = await (Application as BootleggerApp).Comms.(videofile);
                    Picasso.With(this).Load(media.Thumb + "?s=300").Fit().CenterInside().Into(FindViewById <ImageView>(Resource.Id.imageplayer));
                }
                else
                {
                    Picasso.With(this).Load("file://" + media.Filename).Fit().CenterInside().Into(FindViewById <ImageView>(Resource.Id.imageplayer));
                }

                break;
            }
        }
Exemple #8
0
        public void Startup()
        {
            /*** NEW PLAYER ***/
            _player = ExoPlayerFactory.NewSimpleInstance(Context, new DefaultTrackSelector());
            _player.PlayWhenReady = true;
            _player.AddListener(this);

            progress?.Dispose();
            clipper?.Dispose();

            progress = new ProgressTracker(_player);
            progress.OnPositionChange += Progress_OnPositionChange;
            clipper = new ProgressTracker(_player, 50);
            clipper.OnPositionChange += Clipper_OnPositionChange;

            _playerView = FindViewById <PlayerView>(Resource.Id.videoview);

            Android.Graphics.Typeface subtitleTypeface = ResourcesCompat.GetFont(Context, Resource.Font.montserratregular);

            var captionStyleCompat = new CaptionStyleCompat(Android.Graphics.Color.White, Android.Graphics.Color.Transparent, Android.Graphics.Color.Transparent, CaptionStyleCompat.EdgeTypeNone, Android.Graphics.Color.Transparent, subtitleTypeface);

            _playerView.SubtitleView.SetStyle(captionStyleCompat);
            _playerView.SubtitleView.SetFractionalTextSize(0.06f);
            //_playerView.SubtitleView.SetFixedTextSize((int)ComplexUnitType.Sp, 10);

            _playerView.SubtitleView.SetBottomPaddingFraction(0.4f);
            _playerView.SubtitleView.TextAlignment = TextAlignment.Center;


            _playerView.Player        = _player;
            _playerView.UseController = true;

            webclient = new OkHttpClient.Builder()
                        .Cache((Context.ApplicationContext as BootleggerApp).FilesCache)
                        .Build();
            httpDataSourceFactory    = new OkHttpDataSourceFactory(webclient, "BootleggerEditor", null);
            extractorsFactory        = new DefaultExtractorsFactory();
            defaultDataSourceFactory = new DefaultDataSourceFactory(Context, "BootleggerEditor");
            /*************/

            _audioPlayer            = ExoPlayerFactory.NewSimpleInstance(Context, new DefaultTrackSelector());
            _audioPlayer.Volume     = 0.4f;
            _audioPlayer.RepeatMode = Player.RepeatModeOne;

            cursor                       = FindViewById <View>(Resource.Id.trackposition);
            seeker                       = FindViewById <RangeSliderControl>(Resource.Id.seeker);
            trackcontrols                = FindViewById <View>(Resource.Id.trackcontrols);
            seeker.LowerValueChanged    += Seeker_LeftValueChanged;
            seeker.UpperValueChanged    += Seeker_RightValueChanged;
            seeker.StepValueContinuously = true;
            track = FindViewById <View>(Resource.Id.track);

            title = FindViewById <TextView>(Resource.Id.title);

            FindViewById <ImageButton>(Resource.Id.fullscreenbtn).Click += Fullscreen_Click;

            videoWrapper = FindViewById(Resource.Id.videoWrapper);

            mFullScreenDialog = new FullScreenVideoDialog(Context, Android.Resource.Style.ThemeBlackNoTitleBarFullScreen);
            mFullScreenDialog.OnAboutToClose += MFullScreenDialog_OnAboutToClose;

            seeker.Visibility = ViewStates.Invisible;
        }
 private IMediaSource GetSourceByUrl(string url)
 {
     var bandwithMeter = new DefaultBandwidthMeter();
     var httpFactory = new DefaultHttpDataSourceFactory(ExoPlayerUtil.GetUserAgent(this, ApplicationInfo.Name), bandwithMeter);
     var factory = new HttpSourceFactory(httpFactory, RequestHeaders);
     var extractorFactory = new DefaultExtractorsFactory();
     var uri = Android.Net.Uri.Parse(url);
     return new ExtractorMediaSource(uri
         , factory
         , extractorFactory, null, null);
 }