J'ai également posté cela sur les forums MSDN - j'espère que ce n'est pas un problème.Création d'un lecteur multimédia de recherche simple avec MediaElement dans WPF
Je suis fondamentalement en train de créer un lecteur vidéo basé sur WPF qui vous permet de chercher dans les médias. J'essaie de l'implémenter en utilisant MediaTimeline (je sais que je peux changer la propriété Position, mais j'ai eu d'autres problèmes que je publierai dans une question séparée). XAML et code-behind sont ci-dessous.
Merci pour la recherche ...
MainWindow.xaml
<Window x:Class="WpfApplication5.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" SizeToContent="WidthAndHeight">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<MediaElement x:Name="mediaElement" Width="320" Height="240" Margin="4" LoadedBehavior="Manual"/>
<Slider x:Name="slider" Grid.Row="1" Margin="4"/>
</Grid>
</Window>
MainWindow.xaml.cs
using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;
namespace WpfApplication5
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
var tl = new MediaTimeline(new Uri(@"c:\temp\!numa.wmv"));
mediaElement.Clock = tl.CreateClock(true) as MediaClock;
mediaElement.MediaOpened += (o, e) =>
{
slider.Maximum = mediaElement.NaturalDuration.TimeSpan.Seconds;
mediaElement.Clock.Controller.Pause();
};
slider.ValueChanged += (o, e) =>
{
mediaElement.Clock.Controller.Seek(TimeSpan.FromSeconds(slider.Value), TimeSeekOrigin.BeginTime);
};
}
}
}
Quelle est la question? –
Salut Thomas, Cela ne fonctionne pas - déplacer le curseur ne cherche pas la vidéo. merci --oleg –