当前位置: 首页>>代码示例>>C#>>正文


C# MediaElement.Stop方法代码示例

本文整理汇总了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());
     }
 }
开发者ID:BlueSky007,项目名称:ExchangeManager,代码行数:16,代码来源:MainWindowHelper.cs

示例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();
        }
开发者ID:kennydo,项目名称:Choreoh,代码行数:20,代码来源:AudioPlay.cs

示例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);
        }
开发者ID:petergolde,项目名称:VirtualEmily,代码行数:21,代码来源:Util.cs

示例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();
             }
         }
     }
 }
开发者ID:JKarathiya,项目名称:SilverlightSite,代码行数:22,代码来源:Gallery.cs

示例5: videoRestart

 /// <summary>
 /// Redemarrer les videos
 /// </summary>
 /// <param name="video">Mur video</param>
 public void videoRestart(MediaElement video)
 {
     video.Stop();
     video.Play();
 }
开发者ID:kingOfTheWar,项目名称:FaceCollection,代码行数:9,代码来源:MaintenanceVideo.cs

示例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();
 }
开发者ID:kingOfTheWar,项目名称:FaceCollection,代码行数:8,代码来源:MaintenanceVideo.cs

示例7: StopMedia

 private void StopMedia(MediaElement media)
 {
     media.Stop();
 }
开发者ID:susheels,项目名称:Know-your-movie,代码行数:4,代码来源:App.xaml.cs

示例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);
         }
     }
 }
开发者ID:SsSanzo,项目名称:BombEISTIv2,代码行数:26,代码来源:PlaySound.cs

示例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;
 }
开发者ID:JoeLee9981,项目名称:MineSweeper,代码行数:10,代码来源:Game.cs

示例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)
            {

            }
        }
开发者ID:BlueSky007,项目名称:ExchangeManager,代码行数:16,代码来源:MainWindowHelper.cs

示例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);

        };

    }
开发者ID:afrog33k,项目名称:eAd,代码行数:41,代码来源:Player.cs

示例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 );
            }
        }
开发者ID:bcrosnier,项目名称:RideOnMotion,代码行数:45,代码来源:MainWindow.xaml.cs


注:本文中的System.Windows.Controls.MediaElement.Stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。