<UserControl x:Class="SilverlightApplication1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
<StackPanel >
<MediaElement Width="600" Height="480" Stretch="Fill" Source="mv/D301.mp4" Autoplay="False" Name="me1" ></MediaElement>
<ProgressBar Name="pb" Width="600" Height="20" VerticalAlignment="Bottom" Foreground="Red" Background="Black" ></ProgressBar>
<Button Name="btn1" Width="100" Height="50" Content="确定" Click="btn1_Click"></Button>
</StackPanel>
</Grid>
</UserControl>
============================================================================================
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using System.Windows.Threading; namespace SilverlightApplication1 { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); } void dt_Tick(object sender,EventArgs e) { pb.Value = me1.Position.TotalMilliseconds; } private void btn1_Click(object sender,RoutedEventArgs e) { me1.Play(); double mvlen = me1.NaturalDuration.TimeSpan.TotalMilliseconds; //获得视频的总毫秒数 pb.Minimum = 0; pb.Maximum = mvlen; dispatcherTimer dt = new dispatcherTimer(); dt.Interval = TimeSpan.FromMilliseconds(50); dt.Tick += new EventHandler(dt_Tick); dt.Start(); } } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。