Exemplo n.º 1
0
 private void MEMediaOpened(object sender, RoutedEventArgs e)
 {
     try
     {
         ME.Play();
     }
     catch { }
 }
Exemplo n.º 2
0
        private void PlayPauseButtonClick(object sender, RoutedEventArgs e)
        {
            try
            {
                if (sender is AppBarButton button && button != null)
                {
                    if (button.DataContext is InstaDirectInboxItem directInboxItem && directInboxItem != null &&
                        directInboxItem.ItemType == InstaDirectThreadItemType.VoiceMedia && directInboxItem.VoiceMedia != null &&
                        directInboxItem.VoiceMedia?.Media?.Audio != null)
                    {
                        if (VoicePlayPauseButton == null)
                        {
                            VoicePlayPauseButton = button;
                        }
                        else if (VoicePlayPauseButton.Tag.ToString() != button.Tag.ToString())
                        {
                            VoicePlayPauseButton.Content = Helper.PlayMaterialIcon;
                            VoicePlayPauseButton         = button;
                        }

                        if (button.Content.ToString() == Helper.PlayMaterialIcon)// play
                        {
                            if (CurrentDirectInboxItem == null)
                            {
                                CurrentDirectInboxItem = directInboxItem;
                                ME.Source = new Uri(directInboxItem.VoiceMedia.Media.Audio.AudioSource);
                            }
                            else if (CurrentDirectInboxItem.ItemId != directInboxItem.ItemId)
                            {
                                CurrentDirectInboxItem = directInboxItem;
                                ME.Source = new Uri(directInboxItem.VoiceMedia.Media.Audio.AudioSource);
                            }
                            else
                            {
                                ME.Play();
                            }

                            button.Content = Helper.PauseMaterialIcon;
                        }
                        else
                        {
                            ME.Pause();
                            button.Content = Helper.PlayMaterialIcon;
                        }
                    }
                }
            }
            catch { }
        }