Vivek Deshmukh

Vivek Deshmukh

  • NA
  • 142
  • 4k

MediaElement.Setsource is not working in user control

Oct 8 2012 7:30 AM

Hello Team,

I want to display and run video file in FlipView. For this i have created one User control which contains MediaElement as

And passing as

IRandomAccessStream videoStream = await ir.ElementAt(i).OpenAsync(FileAccessMode.ReadWrite);
UCVideoPlayer uc = new UCVideoPlayer(videoStream, ir.ElementAt(i).ContentType);
fvPreviewer.Items.Add(uc);

Here ir is my storagefile Array and fvPreviewer is FlipView control.

In Usercontrol- name is (UCVideoPlayer)

Design-

<MediaElement x:Name="VideoSource" AutomationProperties.Name="VideoSource"   HorizontalAlignment="Center" VerticalAlignment="Center" Height="360" Width="640" AutoPlay="True" PosterSource="Assets/poster.png" IsLooping="True"/>

Initializing as

  public UCVideoPlayer(IRandomAccessStream VideoStream, string ContentType)
        {
            this.InitializeComponent();
           VideoSource.SetSource(VideoStream, ContentType);
           VideoSource.Position = new TimeSpan(0, 0, 50000);   
        }

Can you please guide me for this ? Why this video file is not getting displayed ?

Thanks in Advance