Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WPF
How to play a url in medial element in wpf?
Posted 14-Jan-13 18:50pm
josh-jw11.1K
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
 
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();
    }
}
  Permalink  
v2
Comments
josh-jw at 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)

  Print Answers RSS
0 OriginalGriff 190
1 Jochen Arndt 155
2 PIEBALDconsult 150
3 Afzaal Ahmad Zeeshan 120
4 DamithSL 115
0 OriginalGriff 5,695
1 DamithSL 4,591
2 Maciej Los 4,012
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 15 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100