本文整理汇总了C#中System.Windows.Controls.MediaElement.Stop方法的典型用法代码示例。如果您正苦于以下问题:C# MediaElement.Stop方法的具体用法?C# MediaElement.Stop怎么用?C# MediaElement.Stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.MediaElement
的用法示例。
在下文中一共展示了MediaElement.Stop方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PlayMedia
public static void PlayMedia(MediaElement mediaElement, MediaSource mediaSource)
{
try
{
if (mediaSource != null && mediaSource.Uri != null)
{
mediaElement.Stop();
mediaElement.Source = mediaSource.Uri;
mediaElement.Play();
}
}
catch (Exception ex)
{
Logger.TraceEvent(System.Diagnostics.TraceEventType.Error, "ManagerConsole.Helper.MediaManager:.\r\n{0}", ex.ToString());
}
}
示例2: playForDuration
public static void playForDuration(Canvas parent, String filename, TimeSpan startPosition, TimeSpan duration)
{
MediaElement songMediaElement = new MediaElement();
parent.Children.Add(songMediaElement);
songMediaElement.LoadedBehavior = MediaState.Manual;
songMediaElement.Volume = 100;
songMediaElement.Source = new Uri(@"" + filename, UriKind.RelativeOrAbsolute);
var dispatcherTimer = new DispatcherTimer();
dispatcherTimer.Tick += new EventHandler((object sender, EventArgs e) =>
{
songMediaElement.Stop();
(sender as DispatcherTimer).Stop();
parent.Children.Remove(songMediaElement);
});
dispatcherTimer.Interval = duration;
songMediaElement.Position = startPosition;
songMediaElement.Play();
dispatcherTimer.Start();
}
示例3: PlayMedia
public static void PlayMedia(MediaElement mediaElement, TimeSpan start, TimeSpan length, bool muted)
{
mediaElement.Stop();
mediaElement.Position = start;
mediaElement.IsMuted = muted;
Console.WriteLine("Playing video at {0}", start);
mediaElement.Play();
DispatcherTimer timer = null;
n++;
int x = n;
timer = new DispatcherTimer(length, DispatcherPriority.Send,
(_s, _e) => {
if (x == n) {
mediaElement.Pause();
timer.Stop();
}
},
mediaElement.Dispatcher);
}
示例4: OnApplyTemplate
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
image = (System.Windows.Controls.Image)GetTemplateChild("Image");
oldImage = (System.Windows.Controls.Image)GetTemplateChild("OldImage");
NextImage = (Storyboard)GetTemplateChild("NextImage");
Sound = (MediaElement)GetTemplateChild("Sound");
if (image != null && oldImage != null && NextImage != null)
{
Initialize = true;
Image = 1;
if (!DesignerProperties.IsInDesignTool)
{
InitTimer();
NextImage.Completed += new EventHandler(AnimationCompleted);
if (Sound != null)
{
Sound.Stop();
}
}
}
}
示例5: videoRestart
/// <summary>
/// Redemarrer les videos
/// </summary>
/// <param name="video">Mur video</param>
public void videoRestart(MediaElement video)
{
video.Stop();
video.Play();
}
示例6: stopVideo
/// <summary>
/// Arreter la video desiree (pendant le zoom avec croix rouge)
/// </summary>
/// <param name="media"></param>
public void stopVideo(MediaElement media)
{
media.Stop();
}
示例7: StopMedia
private void StopMedia(MediaElement media)
{
media.Stop();
}
示例8: LoadAllMusic
public void LoadAllMusic()
{
TypeMusicList.Clear();
TypeSoundList.Clear();
foreach (var td in ThemeData)
{
if (td.Value.EndsWith(".wav"))
{
var sound = new SoundPlayer(GameParameters.Path + td.Value);
sound.LoadAsync();
TypeSoundList.Add(td.Key, sound);
}
else if (td.Value.EndsWith(".mp3"))
{
var u = new Uri(GameParameters.Path + td.Value);
var sound = new MediaElement();
sound.Source = u;
sound.LoadedBehavior = MediaState.Manual;
sound.Volume = 0;
sound.Play();
sound.Stop();
sound.Volume = 0.8;
TypeMusicList.Add(td.Key, sound);
}
}
}
示例9: InitializeMediaElement
private MediaElement InitializeMediaElement()
{
MediaElement element = new MediaElement();
element.LoadedBehavior = MediaState.Manual;
element.UnloadedBehavior = MediaState.Stop;
element.MediaEnded += new System.Windows.RoutedEventHandler(
(o, e) => element.Stop());
element.Source = new System.Uri("Sounds/MineSweeper.mp3", UriKind.Relative);
return element;
}
示例10: PlayMedia
public static void PlayMedia(MediaElement mediaElement, MediaSource mediaSource)
{
try
{
if (mediaSource != null && mediaSource.Uri != null)
{
mediaElement.Stop();
mediaElement.Source = mediaSource.Uri;
mediaElement.Play();
}
}
catch (Exception ex)
{
}
}
示例11: CurrentControlOnMediaOpened
private RoutedEventHandler CurrentControlOnMediaOpened(MediaElement lastControl)
{
return delegate(object j, RoutedEventArgs y)
{
this.CurrentControl.Visibility = Visibility.Visible;
DoubleAnimation animation = new DoubleAnimation(0.0, 1.0, new Duration(TimeSpan.FromMilliseconds(1300.0)));
DoubleAnimation animation2 = new DoubleAnimation(1.0, 0.0, new Duration(TimeSpan.FromMilliseconds(1300.0)));
animation.AutoReverse = false;
animation2.AutoReverse = false;
animation2.Completed += delegate(object f, EventArgs k)
{
lastControl.Stop();
lastControl.Visibility = Visibility.Hidden;
};
animation.Completed += delegate(object f, EventArgs k)
{
lastControl.Stop();
lastControl.Visibility = Visibility.Hidden;
};
lastControl.BeginAnimation(UIElement.OpacityProperty, animation2);
this.CurrentControl.BeginAnimation(UIElement.OpacityProperty, animation);
};
}
示例12: OnPreviewKeyDown
protected override void OnPreviewKeyDown( KeyEventArgs e )
{
this.mainWindowViewModel.OnPreviewKeyDown( e );
// konami code management.
if ( _originalBackground == null )
{
_originalBackground = MainPanel.Background;
_originalViewBox = DepthViewerPanel.Children[0];
}
string i = "UpUpDownDownLeftRightLeftRightBA";
if ( e.Key.ToString() == "Up" && _konami != "Up" )
{
_konami = "";
}
_konami = ( _konami + e.Key.ToString() );
// Debug.Print(konami)
if ( ( _konami == i ) )
{
mainWindowViewModel.Konami = true;
string fileName = "..\\..\\Resources\\mad_duck.jpg";
System.Windows.Media.Imaging.BitmapImage image = new System.Windows.Media.Imaging.BitmapImage( new System.Uri( fileName, System.UriKind.Relative ) );
System.Windows.Media.ImageBrush brush = new System.Windows.Media.ImageBrush();
brush.ImageSource = image;
MainPanel.Background = brush;
Viewbox v = new Viewbox();
MediaElement me = new MediaElement();
fileName = "..\\..\\Resources\\Star Wars Ducks.mp4";
me.Source = new System.Uri( fileName, System.UriKind.Relative );
me.LoadedBehavior = MediaState.Manual;
me.MediaEnded += new RoutedEventHandler( delegate( object s, RoutedEventArgs re ) { me.Stop(); me.Play(); } );
me.Play();
v.Child = me;
DepthViewerPanel.Children.RemoveAt( 0 );
DepthViewerPanel.Children.Add( v );
}
else if ( _konami.Length > i.Length )
{
mainWindowViewModel.Konami = false;
MainPanel.Background = _originalBackground;
DepthViewerPanel.Children.RemoveAt( 0 );
DepthViewerPanel.Children.Add( _originalViewBox );
}
}