Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

How I can make wahtsapp like button

$
0
0

I need a mic button on my chatapp to record voice and when release it send the file
so I am trying to add my button in the view then when user click i assign the LongEvent click to hold button but this event not fired although the Touch events work fine,

.....
_recordBtn.LongClickable = true;
_recordBtn.LongClick += _recordBtn_Hold;
_recordBtn.Touch += _recordBtn_Touch;

and my events like

   private void _recordBtn_Hold(object sender, LongClickEventArgs e)
        {
            Toast.MakeText(this.Context, "Recording", ToastLength.Long).Show();
            recorder = new AudioRecorderService
            {
                StopRecordingOnSilence = false,
                StopRecordingAfterTimeout = false
            };
            //alternative event-based API can be used here in lieu of the returned recordTask used below
            //recorder.AudioInputReceived += Recorder_AudioInputReceived;
            player = new AudioPlayer();
             RecordAudio();
        }

 private  async void _recordBtn_Touch(object sender, Android.Views.View.TouchEventArgs e)
        {
   switch (e.Event.Action)
            {
                   case MotionEventActions.Up:
                    if (recorder !=null && recorder.IsRecording)
                    {
                        await StopRecord();
                        Toast.MakeText(this.Context, recorder.GetAudioFilePath(), ToastLength.Long).Show();
                         Toast.MakeText(this.Context, "Up Event Called", ToastLength.Long).Show();
                    }
                    else
                    {
                        Toast.MakeText(this.Context,"Not record any things", ToastLength.Long).Show();
                    }
                     break;
           }

I also found this lib on nuget package it provide exactly what i need but I don't know how i can use it inside my app if any one can help me
Karamunting.Android.3llomi.RecordView
Thanks in advanced


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>