當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。