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


C# MediaElement.Pause方法代码示例

本文整理汇总了C#中System.Windows.Controls.MediaElement.Pause方法的典型用法代码示例。如果您正苦于以下问题:C# MediaElement.Pause方法的具体用法?C# MediaElement.Pause怎么用?C# MediaElement.Pause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Controls.MediaElement的用法示例。


在下文中一共展示了MediaElement.Pause方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LADSVideoBubble

        public LADSVideoBubble(String filename, double width, double height)
        {
            _filename = filename;
            _video = new MediaElement();
            _controls = new VideoItem();
            _sliderTimer = new DispatcherTimer();
            _preferredSize = new Size(width, height);

            _layoutRoot = new Grid();

            _video.MediaOpened += new RoutedEventHandler(video_MediaOpened);
            _video.MediaEnded += new RoutedEventHandler(video_MediaEnded);
            _video.ScrubbingEnabled = true;
            _video.LoadedBehavior = MediaState.Manual;
            _video.Source = new Uri(_filename, UriKind.RelativeOrAbsolute);

            //fire the MediaOpened event
            _video.Play();
            _video.Pause();

            _controls.HorizontalAlignment = HorizontalAlignment.Center;
            _controls.VerticalAlignment = VerticalAlignment.Center;
            _controls.Hide();

            _controls.playButton.Click += new RoutedEventHandler(playButton_Click);
            _controls.stopButton.Click += new RoutedEventHandler(stopButton_Click);
            _controls.videoSlider.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(videoSlider_PreviewMouseLeftButtonDown);
            _controls.videoSlider.PreviewMouseLeftButtonUp += new MouseButtonEventHandler(videoSlider_PreviewMouseLeftButtonUp);
            _controls.videoSlider.PreviewTouchDown += new System.EventHandler<TouchEventArgs>(videoSlider_PreviewTouchDown);
            _controls.videoSlider.PreviewTouchUp += new System.EventHandler<TouchEventArgs>(videoSlider_PreviewTouchUp);

            _controls.videoSlider.IsMoveToPointEnabled = false;
            _controls.videoSlider.SmallChange = 0;
            _controls.videoSlider.LargeChange = 0;

            _sliderTimer.Interval = new TimeSpan(0, 0, 0, 0, SLIDER_TIMER_RESOLUTION);
            _sliderTimer.Tick += new EventHandler(sliderTimer_Tick);

            _layoutRoot.RowDefinitions.Add(new RowDefinition());
            _layoutRoot.RowDefinitions.Add(new RowDefinition());
            _layoutRoot.RowDefinitions[1].Height = new GridLength(50);
            Grid.SetRow(_controls, 1);
            Grid.SetRow(_video, 0);
            _layoutRoot.Children.Add(_video);

            this.AddChild(_layoutRoot);
            //this.MouseEnter += new MouseEventHandler(VideoBubble_MouseEnter);
            //this.MouseLeave += new MouseEventHandler(VideoBubble_MouseLeave);
            this.SizeChanged += new SizeChangedEventHandler(LADSVideoBubble_SizeChanged);
        }
开发者ID:huylu,项目名称:brownuniversitylads,代码行数:50,代码来源:VideoBubble.cs

示例2: 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

示例3: AssociatedDocListBoxItem

        public AssociatedDocListBoxItem(String labeltext, String imageUri, String _scatteruri, ArtworkModeWindow lb, string description)
        {
            _helpers = new Helpers();
            _description = description;
            scatteruri = _scatteruri;
            _lb = lb;
            opened = false;
            dp = new DockPanel();
            this.Content = dp;
            //if image
            if (_helpers.IsImageFile(_scatteruri))
            {
                image = new Image();
                _helpers = new Helpers();

                FileStream stream = new FileStream(imageUri, FileMode.Open);

                System.Drawing.Image dImage = System.Drawing.Image.FromStream(stream);
                System.Windows.Controls.Image wpfImage = _helpers.ConvertDrawingImageToWPFImage(dImage);
                stream.Close();

                wpfImage.SetCurrentValue(DockPanel.DockProperty, Dock.Left);

                wpfImage.SetCurrentValue(HeightProperty, 50.0);
                wpfImage.SetCurrentValue(WidthProperty, 50 * wpfImage.Source.Width / wpfImage.Source.Height);

                dp.Children.Add(wpfImage);

                label = new Label();
                label.Content = labeltext;
                label.FontSize = 18;
                label.SetCurrentValue(DockPanel.DockProperty, Dock.Right);
                dp.Children.Add(label);
                this.PreviewTouchDown += new EventHandler<TouchEventArgs>(onTouch);
                this.PreviewMouseDown += new MouseButtonEventHandler(onTouch);
                lb.getAssociatedDocToolBar().Items.Add(this);
            }

            //equivalent for videos
            else if (_helpers.IsVideoFile(_scatteruri))
            {
                if (_helpers.IsDirShowFile(_scatteruri)) //can easily create nice thumbnails of the video using DirectShow
                {
                    image = new Image();

                    imageUri = System.IO.Path.GetFullPath(imageUri);
                    int decrement = System.IO.Path.GetExtension(imageUri).Length;
                    imageUri = imageUri.Remove(imageUri.Length - decrement, decrement);
                    imageUri += ".bmp";
                    FileStream stream = new FileStream(imageUri, FileMode.Open);

                    System.Drawing.Image dImage = System.Drawing.Image.FromStream(stream);
                    System.Windows.Controls.Image wpfImage = _helpers.ConvertDrawingImageToWPFImage(dImage);
                    stream.Close();

                    wpfImage.SetCurrentValue(DockPanel.DockProperty, Dock.Left);
                    wpfImage.SetCurrentValue(HeightProperty, 50.0);
                    wpfImage.SetCurrentValue(WidthProperty, 50 * wpfImage.Source.Width / wpfImage.Source.Height);

                    dp.Children.Add(wpfImage);

                    label = new Label();
                    label.Content = labeltext;
                    label.FontSize = 18;
                    label.SetCurrentValue(DockPanel.DockProperty, Dock.Right);
                    dp.Children.Add(label);
                    this.PreviewTouchDown += new EventHandler<TouchEventArgs>(onTouch);
                    this.PreviewMouseDown += new MouseButtonEventHandler(onTouch);
                    lb.getAssociatedDocToolBar().Items.Add(this);
                }
                //Code for not actually creating thumbnails of videos, but instead creating paused, unplayable media elements to act as thumbnails
                else
                {
                    MediaElement thumVid = new MediaElement();
                    thumVid.Source = new Uri(scatteruri, UriKind.RelativeOrAbsolute);

                    thumVid.LoadedBehavior = MediaState.Manual;
                    thumVid.ScrubbingEnabled = true;
                    thumVid.Play();
                    thumVid.Pause();

                    thumVid.Position = new TimeSpan(0, 0, 0, 0);
                    thumVid.SetCurrentValue(DockPanel.DockProperty, Dock.Left);
                    thumVid.SetCurrentValue(HeightProperty, 50.0);
                    thumVid.SetCurrentValue(WidthProperty, 50 * thumVid.Width / thumVid.Height);

                    dp.Children.Add(thumVid);

                    label = new Label();
                    label.Content = labeltext;
                    label.FontSize = 18;
                    label.SetCurrentValue(DockPanel.DockProperty, Dock.Right);
                    dp.Children.Add(label);
                    this.PreviewTouchDown += new EventHandler<TouchEventArgs>(onTouch);
                    this.PreviewMouseDown += new MouseButtonEventHandler(onTouch);
                    lb.getAssociatedDocToolBar().Items.Add(this);
                }
            }
        }
开发者ID:huylu,项目名称:brownuniversitylads,代码行数:99,代码来源:DockableItem.cs

示例4: InitialiseFlickerVideo

 private static void InitialiseFlickerVideo(MediaElement flicker)
 {
     flicker.AutoPlay = false;
     flicker.Volume = 0.7;
     flicker.Opacity = 0.6;
     flicker.HorizontalAlignment = HorizontalAlignment.Stretch;
     flicker.VerticalAlignment = VerticalAlignment.Stretch;
     flicker.Stretch = Stretch.Fill;
     flicker.Visibility = Visibility.Collapsed;
     flicker.Position = TimeSpan.Zero;
     flicker.Pause();
 }
开发者ID:andrewmyhre,项目名称:andrewmyhredotcom,代码行数:12,代码来源:tv.xaml.cs

示例5: DeactivateFlickerVideo

 private static void DeactivateFlickerVideo(MediaElement flicker)
 {
     flicker.Pause();
     flicker.Visibility = Visibility.Collapsed;
     flicker.Position = TimeSpan.Zero;
 }
开发者ID:andrewmyhre,项目名称:andrewmyhredotcom,代码行数:6,代码来源:tv.xaml.cs

示例6: scatterItem_Loaded


//.........这里部分代码省略.........
                //textBoxScroll.Visibility = Visibility.Collapsed;

                HotspotTextBox.Visibility = Visibility.Hidden;
                myMediaElement.MediaOpened += new RoutedEventHandler(myMediaElement_MediaOpened);
                myMediaElement.MediaEnded += new RoutedEventHandler(myMediaElement_MediaEnded); //need to fill in method
                myMediaElement.LoadedBehavior = MediaState.Manual;
                String audioUri = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\Data\\Hotspots\\Audios\\" + m_hotspotData.Description;
                myMediaElement.Source = new Uri(audioUri);
                AudioScroll.Visibility = Visibility.Visible;
                timelineSlider.Visibility = Visibility.Visible;
                VideoStackPanel.Visibility = Visibility.Collapsed;

                AudioScroll.Width = hotspotCanvas.Width - 24;
                AudioScroll.Height = hotspotCanvas.Height + AudioTextbox.ActualHeight - 47;

                if (m_hotspotData.fileDescription == "")
                {
                    AudioTextbox.Visibility = Visibility.Hidden;

                }
                else
                {
                    AudioTextbox.Content = "Description:  " + m_hotspotData.fileDescription;
                    AudioTextbox.Width = hotspotCanvas.Width;
                }
                this.UpdateLayout();

                AudioTextbox.Width = this.ActualWidth-8;

                hotspotCanvas.SetCurrentValue(HeightProperty, hotspotCanvas.Height + AudioTextbox.ActualHeight+40);
                this.SetCurrentValue(HeightProperty, hotspotCanvas.Height+8);
                //fire Media Opened in order to set the actual length
                myMediaElement.Play();
                myMediaElement.Pause();
                this.CanScale = false;
                PlayButton.Click += new RoutedEventHandler(PlayButton_Click);
                PauseButton.Click += new RoutedEventHandler(PauseButton_Click);
                StopButton.Click += new RoutedEventHandler(StopButton_Click);

                this.showAudioIcon();

                _dragging = false;
                _sliderTimer = new System.Windows.Threading.DispatcherTimer();

                timelineSlider.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(timelineSlider_PreviewMouseLeftButtonDown);
                timelineSlider.PreviewMouseLeftButtonUp += new MouseButtonEventHandler(timelineSlider_PreviewMouseLeftButtonUp);
                timelineSlider.PreviewTouchDown += new System.EventHandler<TouchEventArgs>(timelineSlider_PreviewTouchDown);
                timelineSlider.PreviewTouchUp += new System.EventHandler<TouchEventArgs>(timelineSlider_PreviewTouchUp);

                timelineSlider.IsMoveToPointEnabled = false;
                timelineSlider.SmallChange = 0;
                timelineSlider.LargeChange = 0;

                _sliderTimer.Interval = new TimeSpan(0, 0, 0, 0, SLIDER_TIMER_RESOLUTION);
                _sliderTimer.Tick += new EventHandler(sliderTimer_Tick);
                _sliderTimer.Stop();

            }
            else if (m_hotspotData.Type.ToLower().Contains("video"))
            {
                String videoUri = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\Data\\Hotspots\\Videos\\" + m_hotspotData.Description;
                videoElement = new MediaElement();
                videoElement.Source = new Uri(videoUri);
                videoTimer = new DispatcherTimer();
                videoTimer.Interval = new TimeSpan(0, 0, 0, 0, 100);
                videoTimer.Tick += new EventHandler(videoTimer_Tick);
开发者ID:huylu,项目名称:brownuniversitylads,代码行数:67,代码来源:HotspotDetailsControl.xaml.cs

示例7: prepare

        public void prepare()
        {
            if (path != null)
            {
                if (mediaElement == null)
                {
                    mediaElement = new MediaElement();
                    MainPage.m_mainPage.LayoutRoot.Children.Add(mediaElement);

                    mediaElement.MediaOpened += mediaElement_MediaOpened;
                    mediaElement.MediaFailed += mediaElement_MediaFailed;
                    mediaElement.MediaEnded += mediaElement_MediaEnded;

                    if (mediaElement.Source == null)
                    {
                        mediaElement.Source = new Uri(path, UriKind.RelativeOrAbsolute);
                        mediaElement.Play();
                        mediaElement.Pause();
                    }
                }
                timeLastPlayed = DateTime.Now;
            }
        }
开发者ID:kariem2k,项目名称:playir,代码行数:23,代码来源:CSAudioManager.cs

示例8: MovieChange

        /// <summary>
        /// MovieChange
        /// </summary>
        /// <param name="message"></param>
        public void MovieChange(MovieChangeMessage message)
        {
            Movie = message.Movie;

            if(Movie == null)
            {
                MovieObj.MediaOpened -= new System.Windows.RoutedEventHandler(MovieObj_MediaOpened);
                return;
            }

            if (MovieObj != null)
            {
                MovieObj.Close();
                MovieObj = null;
            }

            MovieObj = new MediaElement()
            {
                LoadedBehavior = MediaState.Manual,
                ScrubbingEnabled = true,
                Stretch = System.Windows.Media.Stretch.Uniform,
            };
            MovieObj.MediaOpened += new System.Windows.RoutedEventHandler(MovieObj_MediaOpened);

            MovieObj.Source = new Uri(Movie.FullPath);
            MovieObj.Pause();

            // Popup Thumbnail
            ThumbMovieObj = new MediaElement()
            {
                LoadedBehavior = MediaState.Manual,
                ScrubbingEnabled = true,
                Stretch = System.Windows.Media.Stretch.Uniform,
            };

            ThumbMovieObj.Source = new Uri(Movie.FullPath);
            ThumbMovieObj.Pause();
        }
开发者ID:ikageso,项目名称:MoviePlayer,代码行数:42,代码来源:MovieControlViewModel.cs


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