本文整理汇总了C#中MediaPlayer.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# MediaPlayer.Dispose方法的具体用法?C# MediaPlayer.Dispose怎么用?C# MediaPlayer.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MediaPlayer
的用法示例。
在下文中一共展示了MediaPlayer.Dispose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMediaElement
//==========================================================================
private static MediaElement GetMediaElement(MediaPlayer mediaPlayer)
{
if(mediaPlayer == null)
return null;
WeakReference<MediaElement> reference;
if(!m_MediaElements.TryGetValue(mediaPlayer, out reference))
return null;
MediaElement media_element = null;
if(reference != null)
if(!reference.TryGetTarget(out media_element))
media_element = null;
if(media_element == null)
{
m_MediaElements.TryRemove(mediaPlayer, out reference);
mediaPlayer.Dispose();
}
return media_element;
}
示例2: OnMediaPlayerChanged
//==========================================================================
private void OnMediaPlayerChanged(MediaPlayer oldValue, MediaPlayer newValue)
{
if(oldValue != null)
{
WeakReference<MediaElement> reference;
m_MediaElements.TryRemove(oldValue, out reference);
oldValue.VideoCleanup -= MediaPlayer_VideoCleanup;
oldValue.Display -= MediaPlayer_Display;
oldValue.VideoFormat -= MediaPlayer_VideoFormat;
oldValue.Event -= MediaPlayer_Event;
oldValue.Dispose();
}
if(newValue != null)
{
m_MediaElements.TryAdd(newValue, new WeakReference<MediaElement>(this));
newValue.Event += MediaPlayer_Event;
newValue.VideoFormat += MediaPlayer_VideoFormat;
newValue.Display += MediaPlayer_Display;
newValue.VideoCleanup += MediaPlayer_VideoCleanup;
newValue.Volume = (int)Math.Round(Volume * 100);
newValue.Location = Source;
State = MediaElementState.Stopped;
}
else
State = MediaElementState.Empty;
IsOpen = false;
VideoBufferBitmap = null;
ActualFPS = null;
FPS = null;
Length = null;
Position = null;
VideoStreams = null;
CurrentVideoStream = null;
AudioStreams = null;
CurrentAudioStream = null;
SubtitleStreams = null;
CurrentSubtitleStream = null;
ChapterCount = null;
CurrentChapter = null;
}