Click here to Skip to main content
16,017,351 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to play a url in medial element in wpf?
Posted

 
Share this answer
 
private void MediaEL_MediaOpened(object sender, RoutedEventArgs e)  
02 {  
03     if (MediaEL.NaturalDuration.HasTimeSpan)  
04     {  
05         TimeSpan ts = MediaEL.NaturalDuration.TimeSpan;  
06         seekBar.Maximum = ts.TotalSeconds;  
07         seekBar.SmallChange = 1;  
08         seekBar.LargeChange = Math.Min(10, ts.Seconds / 10);  
09     }  
10     timer.Start(); 
11}
12 




or

C#
public MainWindow()
{
    BoxedAppSDK.NativeMethods.BoxedAppSDK_Init();

    InitializeComponent();
}

private void button2_Click(object sender, RoutedEventArgs e)
{
    var MyFileStream = new CustomFileStream(File.ReadAllBytes(@"wildlife.wmv"));

    IntPtr ptr = BoxedAppSDK.NativeMethods.BoxedAppSDK_CreateVirtualFileBasedOnIStream(
            @"1.wmv",
            BoxedAppSDK.NativeMethods.EFileAccess.GenericWrite,
            BoxedAppSDK.NativeMethods.EFileShare.Read,
            IntPtr.Zero,
            BoxedAppSDK.NativeMethods.ECreationDisposition.New,
            BoxedAppSDK.NativeMethods.EFileAttributes.Normal,
            IntPtr.Zero,
            MyFileStream);

    using (new SafeFileHandle(ptr, true))
    {
        mediaElement1.Source = new Uri(Path.GetFullPath("1.wmv"));
        mediaElement1.LoadedBehavior = MediaState.Manual;
        mediaElement1.Play();
    }
}
 
Share this answer
 
v2
Comments
josh-jw 15-Jan-13 0:04am    
how can i add a url as source in media element.i use like
this.videoelement.Source = new Uri(@"http://www.youtube.com/watch?v=r-04JH7GGCI", UriKind.Absolute);
its not working

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900