async Vlc disposal

This commit is contained in:
Paddy Xu
2017-08-01 23:39:44 +03:00
parent a5320b28ee
commit 3994039864

View File

@@ -19,6 +19,7 @@ using System;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using Meta.Vlc; using Meta.Vlc;
@@ -34,13 +35,13 @@ namespace QuickLook.Plugin.VideoViewer
public partial class ViewerPanel : UserControl, IDisposable, INotifyPropertyChanged public partial class ViewerPanel : UserControl, IDisposable, INotifyPropertyChanged
{ {
private readonly ContextObject _context; private readonly ContextObject _context;
private string _coverArt; private string _coverArt;
private bool _hasAudio; private bool _hasAudio;
private bool _hasEnded; private bool _hasEnded;
private bool _hasVideo; private bool _hasVideo;
private bool _isMuted; private bool _isMuted;
private bool _isPlaying; private bool _isPlaying;
private bool _wasPlaying; private bool _wasPlaying;
public ViewerPanel(ContextObject context) public ViewerPanel(ContextObject context)
@@ -163,15 +164,16 @@ namespace QuickLook.Plugin.VideoViewer
{ {
try try
{ {
//if (mediaElement != null && !mediaElement.VlcMediaPlayer.CanPlay) Task.Run(() =>
// Thread.Sleep(200); {
mediaElement?.Dispose(); mediaElement?.Dispose();
mediaElement = null;
});
} }
catch (Exception e) catch (Exception e)
{ {
Debug.WriteLine(e); Debug.WriteLine(e);
} }
mediaElement = null;
} }
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;