本文介绍了在媒体元素中播放网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在wpf中的medial元素中播放url?
How to play a url in medial element in wpf?
推荐答案目前无法将流分配为媒体元素。可能的解决方案将是.. stackoverflow/questions/7117589/使用-mediaelement-to-play-video-from-stream [ ^ ] stackoverflow/questions/7136213/playing-streaming-video-in-wpf [ ^ ] Assigning a Stream as media element is currently not possible.Possible solutions would be.. stackoverflow/questions/7117589/using-mediaelement-to-play-video-from-stream[^] stackoverflow/questions/7136213/playing-streaming-video-in-wpf[^]
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(); } }
更多推荐
在媒体元素中播放网址
发布评论