Search code examples
androidxamarinxamarin.androidandroid-mediaplayerandroid-videoview

MEDIA_INFO_BUFFERING_START not found in xamarin android?


I am currently working with Mediaplayer in Xamarin android. There are MediaPlayer.MEDIA_INFO_BUFFERING_START and MediaPlayer.MEDIA_INFO_BUFFERING_END in native android(java). But I cannot find these MEDIA_INFO_BUFFERING_START and MEDIA_INFO_BUFFERING_START for Xamarin. My code in android studio:

  mediaPlayer.setOnInfoListener(new MediaPlayer.OnInfoListener() {
        @Override
        public boolean onInfo(MediaPlayer mp, int what, int extra) {
            switch (what) {
                case MediaPlayer.MEDIA_INFO_BUFFERING_START:
                    AppLog.showLogE(TAG,"Buffering...");
                    progressView.setVisibility(View.VISIBLE);
                    break;
                case MediaPlayer.MEDIA_INFO_BUFFERING_END:
                    AppLog.showLogE(TAG,"Buffering End");
                    progressView.setVisibility(View.GONE);
                    break;
            }
            return false;
        }
    });

In Xamarin Android I am stuck here:

    public bool OnInfo(MediaPlayer mp, [GeneratedEnum] MediaInfo what, int extra)
    {
        switch (what)
        {
            case MediaPlayer. //not found

                    break;
        }
        return false;
    }

Solution

  • Well, this is how you do it on xamarin android, I hope this is what you are looking for :

     switch (what) {
                case Android.Media.MediaInfo.BufferingStart:
                    //AppLog.showLogE(TAG,"Buffering...");
                    progressView.Visibility=(ViewStates.Visible);
                    break;
                case Android.Media.MediaInfo.BufferingEnd:
                    //AppLog.showLogE(TAG,"Buffering End");
                    progressView.Visibility=(ViewStates.Gone);
                    break;
            }
    

    Goodluck! Happy coding.