.Net Project/SilverLight 3.0

12장) 실버라이트 동영상 처리 (MediaElement)

래곤 2009. 11. 26. 13:39
반응형
RiaMediaElement


미디어 동영상 화면 처리
 
 

<UserControl x:Class="RiaMediaElement.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

                x:Name="myVideo" Source="Video/Silverlight.wmv"

                AutoPlay="False" IsMuted="False">

            </MediaElement>

            <StackPanel Orientation="Horizontal">

                <Button x:Name="btnStart" Content="재생"></Button>

                <Button x:Name="btnStop" Content="중지"></Button>

            </StackPanel>

        </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;

 

namespace RiaMediaElement

{

    public partial class MainPage : UserControl

    {

        public MainPage()

        {

            InitializeComponent();

 

            btnStart.Click += new RoutedEventHandler(btnStart_Click);

            btnStop.Click += new RoutedEventHandler(btnStop_Click);

        }

 

        void btnStop_Click(object sender, RoutedEventArgs e)

        {

            myVideo.Stop(); // 중지
        }

 

        void btnStart_Click(object sender, RoutedEventArgs e)

        {

            //myVideo.AutoPlay = true;

            myVideo.Play(); // 재생

        }

    }

} 





반응형