如何在xamarin.forms中获得媒体播放器文件播放完成事件?

时间:2019-04-15 09:38:51

标签: c# xamarin.forms

文件播放完成后,我需要获取事件完成通知,以了解如何在xamarin.forms内实现

public void PlayAudioFile(String pathtowavfile)
        {
            try
            {
                var fileresouce = new Java.IO.File(pathtowavfile);
                if (fileresouce.Exists())
                {
                    player.Reset();
                    player.SetDataSource(pathtowavfile);
                    player.Prepare();

                    player.Completion += Player_Completion;
                }
            }
            catch (Exception ex)
            {
            }

        }

        private void Player_Completion(object sender, EventArgs e)
        {
            throw new NotImplementedException();
        }

        public void Start()
        {
            player.SeekTo(length);
            player.Start();
        }
        public void Pause()
        {
            if (player.IsPlaying)
            {
                player.Pause();
                length = player.CurrentPosition;
            }
        }

0 个答案:

没有答案