zoukankan      html  css  js  c++  java
  • SL中MediaElement(视频播放)

     1 <UserControl x:Class="SL1.SLMedia"
     2     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     3     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     4     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
     5     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
     6     mc:Ignorable="d"
     7     d:DesignHeight="300" d:DesignWidth="400">
     8     
     9     <Grid x:Name="LayoutRoot" Background="White">
    10         <MediaElement x:Name="mePalyer" MinWidth="1"  Source="vedio/1.mp4" Margin="0,0,0,50" MediaOpened="mePalyer_MediaOpened"></MediaElement>
    11         <Button x:Name="btnPlay" Content="播放" VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="20,20"  FontFamily="Arial Black" FontSize="25" Click="btnPlay_Click"></Button>
    12                 <Button x:Name="btnStop" Content="暂停" VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="100,20"  FontFamily="Arial Black" FontSize="25" Click="btnStop_Click">
    13         </Button>
    14         <ProgressBar x:Name="pbTimer" HorizontalAlignment="Left" Height="35" Margin="180,245,0,20" VerticalAlignment="Bottom" Width="210" Minimum="1"  Loaded="ProgressBar_Loaded_1" />
    15 
    16     </Grid>
    17 </UserControl>
     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Net;
     5 using System.Windows;
     6 using System.Windows.Controls;
     7 using System.Windows.Documents;
     8 using System.Windows.Input;
     9 using System.Windows.Media;
    10 using System.Windows.Media.Animation;
    11 using System.Windows.Shapes;
    12 using System.Windows.Threading;
    13 
    14 namespace SL1
    15 {
    16     public partial class SLMedia : UserControl
    17     {
    18         public SLMedia()
    19         {
    20             InitializeComponent();
    21         }
    22 
    23         private void btnPlay_Click(object sender, RoutedEventArgs e)
    24         {
    25             mePalyer.Play();
    26         }
    27 
    28         private void btnStop_Click(object sender, RoutedEventArgs e)
    29         {
    30            // mePalyer.Stop();
    31             mePalyer.Pause();
    32         }
    33 
    34         private void ProgressBar_Loaded_1(object sender, RoutedEventArgs e)
    35         {
    36          
    37         }
    38 
    39         void tick_Tick(object sender, EventArgs e)
    40         {
    41            // pbTimer.Value += 3;
    42             pbTimer.Value= mePalyer.Position.TotalMilliseconds;
    43         }
    44 
    45         private void mePalyer_MediaOpened(object sender, RoutedEventArgs e)
    46         {
    47             pbTimer.Maximum = mePalyer.NaturalDuration.TimeSpan.TotalMilliseconds;       
    48             DispatcherTimer tick = new DispatcherTimer();
    49             tick.Tick += tick_Tick;
    50             tick.Interval = TimeSpan.FromMilliseconds(500);
    51             tick.Start();
    52         }
    53 
    54       
    55     }
    56 }

     

  • 相关阅读:
    使用部分函数时并未include其所在头文件,但是能编译成功且能运行,为什么?
    ubuntu开发机所需工具,做个记录,不断补充
    c cpp编程用到的系统边角与其拾遗
    几个递进的make file
    可以用命令行控制eclipse断点增加删除、远程调试创建与启动的插件
    Mac 从睡眠恢复后没有声音的问题
    [netty4][netty-handler]netty之idle handler处理
    《将博客搬至CSDN》
    python2与python3中__metacalss__的不同用法
    python3 type和object的关系
  • 原文地址:https://www.cnblogs.com/rockman/p/3367475.html
Copyright © 2011-2022 走看看