win8应用简单实现视频播放

前台    

<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
        <MediaElement x:Name="media" Source="video/1.mp4" AutoPlay="False" Height="500" Width="700" PlaybackRate="{Binding value,ElementName=slider1,Mode=TwoWay}"   RealTimePlayback="True" ></MediaElement>
        <Button Content="播放" FontSize="40" Name="playbtn" Margin="67,236,0,460" Click="playbtn_Click_1"></Button>
        <Button Content="停止" FontSize="40" Name="stopbtn" Margin="69,496,0,200" Click="stopbtn_Click_1"></Button>
        <Button Content="暂停" FontSize="40" Name="suspendedbtn" Margin="66,370,0,326" Click="suspendedbtn_Click" ></Button>
        <Slider HorizontalAlignment="Left" Name="slider1" Maximum="100" Minimum="0"  Margin="347,628,0,0" VerticalAlignment="Top" Width="673"/>
    </Grid>

后台

private void playbtn_Click_1(object sender, RoutedEventArgs e)
        {
            media.Play();
        }

        private void stopbtn_Click_1(object sender, RoutedEventArgs e)
        {
            media.Stop();
        }

        private void suspendedbtn_Click(object sender, RoutedEventArgs e)
        {
            media.Pause();
        }

你可能感兴趣的:(win8)