Click here to Skip to main content
12,451,455 members (60,543 online)
Rate this:
 
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 17:50pm
josh-jw16.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 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160826.1 | Last Updated 15 Jan 2013
Copyright © CodeProject, 1999-2016
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