locked
mediaelement RRS feed

  • Question

  • how to add video in windows store app using c#??

    Thursday, November 14, 2013 6:33 PM

Answers

All replies

  • Thursday, November 14, 2013 6:35 PM
    Moderator
  • i am insert the code xaml an code c# ... but not is working ...??

    Thursday, November 14, 2013 7:06 PM
  • Add the MediaElement to the xaml and from code behind you can work with it. Set source of video to Source property of MediaElement and invoke Play command.
    Thursday, November 14, 2013 8:06 PM
  • yes i do it but not is work :(

    like this :

    xmal code :

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
            <MediaElement x:Name="media" Source="Assets/a1.flv"  
                  Grid.Column="0" Grid.Row="0"  AutoPlay="True" />
            <Button Click="StopMedia" Grid.Column="0" Grid.Row="1" Content="Stop" />
            <Button Click="PauseMedia"  Grid.Column="1" Grid.Row="1" Content="Pause" />
            <Button Click="PlayMedia" Grid.Column="2" Grid.Row="1" Content="Play" />
        </Grid>

    c# code :

    namespace newVideo
    {
        /// <summary>
        /// An empty page that can be used on its own or navigated to within a Frame.
        /// </summary>
        public sealed partial class MainPage : Page
        {
            public MainPage()
            {
                this.InitializeComponent();
            }

            private void StopMedia(object sender, RoutedEventArgs e)
            {
                media.Stop();
            }
            private void PauseMedia(object sender, RoutedEventArgs e)
            {
                media.Pause();
            }
            private void PlayMedia(object sender, RoutedEventArgs e)
            {
                media.Source = new Uri(this.BaseUri, "Assets/a1.flv");
                media.Play();
            }

            protected override async void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
            {
                media.MediaEnded += media_MediaEnded;

            }

            private void media_MediaEnded(object sender, RoutedEventArgs e)
            {
                media.Source = new Uri(this.BaseUri, "Assets/page1/para2.mp3");
                media.Play();
            }
        }
    }


    Thursday, November 14, 2013 8:23 PM
  • FLV files aren't supported out of the box. Your best bet will be to switch to a supported format. See Supported audio and video formats

    --Rob

    Thursday, November 14, 2013 8:25 PM
    Moderator
  • ahaa .. ok i will try agin ..thanx

    Thursday, November 14, 2013 8:59 PM
  • i try it to replace video.flv with video.mp4, but not is work ....???

    Thursday, November 14, 2013 9:08 PM