public override void DisposePlayer()
 {
     _mediaElement.MediaOpened  -= MediaElement_MediaOpened;
     _mediaElement.MediaFailed  -= MediaElement_MediaFailed;
     _mediaElement.MediaEnded   -= MediaElement_MediaEnded;
     _mediaElement.MediaOpening -= MediaElement_MediaOpening;
     _mediaElement.Close();
     _mediaElement.Dispose();
 }
 public async Task HideVideoAsync(Guid mediaItemId)
 {
     if (_mediaItemId == mediaItemId)
     {
         OnMediaChangeEvent(new MediaEventArgs {
             MediaItemId = _mediaItemId, Change = MediaChange.Stopping
         });
         await _mediaElement.Close();
     }
 }
Beispiel #3
0
        public void stop()
        {
            this.mediaElement.Stop();

            mediaElement.Close();
            playstate = 0;
            timer.Stop();
            //this.Close();
            //listBox.IsEnabled = true;
        }
Beispiel #4
0
 private void timer_TickStarting(object sender, EventArgs e)
 {
     if (_seconds != 0)
     {
         _media.Volume -= _pace;
         _seconds      -= 1;
     }
     else
     {
         _media.Stop();
         _media.Close();
         _timer.Tick -= timer_TickStarting;
     }
 }
        public void PageUnloaded()
        {
            Application.Current.Dispatcher.Invoke(async() =>
            {
                await MediaElement.Stop();
                await MediaElement.Close();

                DispatcherTimer.IsEnabled = false;
                DispatcherTimer.Stop();

                if (SpendTime.TotalSeconds > 10)
                {
                    using var db = new AppDbContext();

                    var spendTime = new SpendTime
                    {
                        ChannelId = Channel.Id,
                        Spendtime = SpendTime
                    };

                    db.SpendTimes.Add(spendTime);
                    db.SaveChanges();
                }
            });
        }
Beispiel #6
0
        /// <summary>
        /// 影片结束后事件,可用来执行影片播放结束想要执行的动作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mediaElement_MediaEnded(object sender, RoutedEventArgs e)
        {
            this.mediaElement.Stop();
            mediaElement.Close();
            //MessageBox.Show("影片播放结束");

            playstate = 0;
            timer.Stop();
            this.Hide();
            //单曲循环
            //mediaElement.Position = new TimeSpan();
            //mediaElement.Play();

            //列表循环
            //for (int i = 0; i < MainWindow.list.Count; i++)
            //{
            //    if (MainWindow.fileName == MainWindow.list[i])
            //    {
            //        if (i == MainWindow.list.Count - 1)
            //        {
            //            this.mediaElement.Source = new Uri(MainWindow.list[0]);
            //            this.mediaElement.Play();
            //        }
            //        else
            //        {
            //            this.mediaElement.Source = new Uri(MainWindow.list[i + 1]);
            //            this.mediaElement.Play();
            //        }
            //        break;
            //    }
            //}
        }
 public void PauseStream()
 {
     Application.Current.Dispatcher.Invoke(async() =>
     {
         await MediaElement.Stop();
         await MediaElement.Close();
     });
 }
Beispiel #8
0
 public void stopPlayback()
 {
     //VideoControl.Stop();
     VideoControl.Close();
     VideoControl.UpdateDefaultStyle();
     videoContainer.Children.Remove(VideoControl);
     VideoControl = null;
 }
Beispiel #9
0
        public void StopSong()
        {
            var          main        = App.Current.MainWindow;
            MediaElement mediaPlayer = (MediaElement)(main.FindName("mediaPlayer"));

            mediaPlayer.Close();
            timer.Stop();
        }
 public override void DisposePlayer()
 {
     _mediaElement.MediaOpened -= MediaElement_MediaOpened;
     _mediaElement.MediaFailed -= MediaElement_MediaFailed;
     _mediaElement.MediaEnded  -= MediaElement_MediaEnded;
     _mediaElement.Close();
     IsMediaLoaded = false;
 }
 public static void release()
 {
     if (w != null)
     {
         me.Close();
         w.Close();
     }
 }
 public void ReloadStream()
 {
     Application.Current.Dispatcher.Invoke(async() =>
     {
         await MediaElement.Stop();
         await MediaElement.Close();
         await MediaElement.Open(new Uri(Channel.M3U8Address));
     });
 }
Beispiel #13
0
        void KMiniPlayer_Unloaded(object sender, RoutedEventArgs e)
        {
            Unloaded -= new RoutedEventHandler(KMiniPlayer_Unloaded);

            if (MediaElement != null)
            {
                // Unsubsribes and clean up
                MediaElement.MediaFailed -= new RoutedMediaFailedEventHandler(MediaElement_MediaFailed);
                MediaElement.Close();
            }
        }
        private void Close()
        {
            ViewModel.Uri = null;
            if (MediaElement is not null)
            {
                MediaElement.Close();
                MediaElement.Source     = null;
                MediaElement.Visibility = Visibility.Collapsed;
            }

            ImageElement.Visibility = Visibility.Collapsed;
        }
Beispiel #15
0
        public void LoadFileSet(TeslaCamFileSet set)
        {
            left.Close();
            right.Close();
            front.Close();
            back.Close();
            bool playLeft  = false;
            bool playRight = false;
            bool playFront = false;
            bool playBack  = false;

            foreach (var cam in set.Cameras)
            {
                if (cam.CameraLocation == TeslaCamFile.CameraType.FRONT)
                {
                    this.front.Source = new Uri(cam.FilePath);
                    playFront         = true;
                }
                if (cam.CameraLocation == TeslaCamFile.CameraType.LEFT_REPEATER)
                {
                    this.left.Source = new Uri(cam.FilePath);
                    playLeft         = true;
                }
                if (cam.CameraLocation == TeslaCamFile.CameraType.RIGHT_REPEATER)
                {
                    this.right.Source = new Uri(cam.FilePath);
                    playRight         = true;
                }
                if (cam.CameraLocation == TeslaCamFile.CameraType.BACK)
                {
                    this.back.Source = new Uri(cam.FilePath);
                    playBack         = true;
                }
            }

            if (playLeft)
            {
                left.Play();
            }
            if (playRight)
            {
                right.Play();
            }
            if (playFront)
            {
                front.Play();
            }
            if (playBack)
            {
                back.Play();
            }
            this.tabs.SelectedIndex = 1;
        }
        private void Shutdown()
        {
            _ShutdownRequest = false;

            _MediaElement.Stop();
            _MediaElement.Close();
            _MediaElement.Source = null;

            _MediaElement.MediaOpened -= MediaPlayer_Opened;
            _MediaElement.MediaEnded  -= MediaPlayer_Ended;
            _MediaElement.MediaFailed -= MediaPlayer_Failed;

            _Phase = Phase.Closed;
        }
Beispiel #17
0
 private void btnClose_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (!IsInSync || IsSyncOwner)
     {
         mediaPlayer.Stop();
         mediaPlayer.Close();
         Close();
         if (IsInSync && IsSyncOwner)
         {
             _003C_003Ec__DisplayClass1a _003C_003Ec__DisplayClass1a = new _003C_003Ec__DisplayClass1a();
             _003C_003Ec__DisplayClass1a.socketClient = Singleton_Socket.GetInstance(MeetingID, UserID, UserName, true);
             Task.Factory.StartNew(new Action(_003C_003Ec__DisplayClass1a._003CbtnClose_MouseLeftButtonDown_003Eb__19));
         }
     }
 }
Beispiel #18
0
        public Task Close()
        {
            _timer.Stop();

            if (_currentMediaClassification == MediaClassification.Audio)
            {
                _audioPlayer.Value.Close();
            }
            else
            {
                _mediaElement.Close();
            }

            MediaClosed?.Invoke(this, null);
            return(Task.CompletedTask);
        }
Beispiel #19
0
        private void addElement_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog
            {
                Multiselect = true
            };

            if (openFileDialog.ShowDialog() == true)
            {
                foreach (string fileName in openFileDialog.FileNames)
                {
                    string path = fileName;
                    string exp  = path.Split("\\").LastOrDefault().Split('.').LastOrDefault();
                    if (Utils.imageExp.Contains(exp))
                    {
                        elements.Add(new PlaylistElement {
                            Path = fileName.Replace("\\", "/")
                        });
                    }

                    if (Utils.videoExp.Contains(exp))
                    {
                        MediaElement video = new MediaElement
                        {
                            Source           = new Uri(path, UriKind.Absolute),
                            LoadedBehavior   = MediaState.Manual,
                            UnloadedBehavior = MediaState.Manual,
                            Volume           = 0
                        };
                        video.MediaOpened += new System.Windows.RoutedEventHandler(Media_MediaOpened);

                        video.Play();
                        while (!video.NaturalDuration.HasTimeSpan)
                        {
                        }                                               //без этой строчки NaturalDuration не успевает вычислиться, и равен Automatic
                        double dur = video.NaturalDuration.TimeSpan.TotalSeconds;
                        video.Close();

                        elements.Add(new PlaylistElement {
                            Path = openFileDialog.FileName.Replace("\\", "/"), Duration = Convert.ToInt32(dur)
                        });
                    }
                }
            }
        }
Beispiel #20
0
        public Task Close()
        {
            _timer.Stop();

            if (_currentMediaClassification == MediaClassification.Audio)
            {
                _audioPlayer.Value.Close();
            }
            else
            {
                _mediaElement.Close();
            }

            IsPaused = false;

            MediaClosed?.Invoke(this, new OnlyMMediaClosedEventArgs());

            return(Task.CompletedTask);
        }
 private void Window_Closing(object sender, CancelEventArgs e)
 {
     if (isClosable)
     {
         if (isInitialized)
         {
             me.Close();
         }
         if (hackedPath.Contains(".mkv") && File.Exists(hackedPath))
         {
             File.Move(hackedPath, hackedPath.Replace(".mkv", ""));
         }
         if (matrixPath.Contains(".mkv") && File.Exists(matrixPath))
         {
             File.Move(matrixPath, matrixPath.Replace(".mkv", ""));
         }
         UnhookWindowsHookEx(intLLKey);
         DisableControls(false);
     }
     else
     {
         e.Cancel = true;
     }
 }
Beispiel #22
0
 public void Dispose()
 {
     MediaElement?.Close();
     //MediaElement?.Dispose();
     MediaElement = null;
 }
Beispiel #23
0
 public void Stop()
 {
     player.Dispatcher.Invoke(() => { player.Source = null; player.Close(); });
 }
Beispiel #24
0
 private void Close()
 {
     ViewModel.Uri = null;
     MediaElement?.Close();
 }
Beispiel #25
0
 public void Stop()
 {
     videoElement.Stop();
     videoElement.Close();
 }
Beispiel #26
0
 private void ButtonClose_Click(object sender, RoutedEventArgs e)
 {
     timer.Stop();
     media.Stop(); media.Close();
     this.Close();
 }