本文整理汇总了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);
}
示例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);
}
示例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);
}
}
}
示例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();
}
示例5: DeactivateFlickerVideo
private static void DeactivateFlickerVideo(MediaElement flicker)
{
flicker.Pause();
flicker.Visibility = Visibility.Collapsed;
flicker.Position = TimeSpan.Zero;
}
示例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);
示例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;
}
}
示例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();
}