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