C# 为什么赢了';t WinRT MediaElement.SetSource应该做什么?

C# 为什么赢了';t WinRT MediaElement.SetSource应该做什么?,c#,windows-runtime,mediaelement,C#,Windows Runtime,Mediaelement,很简单。使用MediaElement时,此代码有效: TestMedia.Source = new Uri("ms-appx:///Assets/Test.mp4"); TestMedia.MediaFailed += TestMedia_MediaFailed; TestMedia.AutoPlay = true; 此代码不包括: StorageFile fileToTest = await StorageFile.GetFileFromApplicationUriAsync(new Uri

很简单。使用
MediaElement
时,此代码有效:

TestMedia.Source = new Uri("ms-appx:///Assets/Test.mp4");
TestMedia.MediaFailed += TestMedia_MediaFailed;
TestMedia.AutoPlay = true;
此代码不包括:

StorageFile fileToTest = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/Test.mp4"));
var stream = await fileToTest.OpenAsync(FileAccessMode.Read);
TestMedia.SetSource(stream, fileToTest.ContentType);
TestMedia.MediaFailed += TestMedia_MediaFailed;
TestMedia.AutoPlay = true;
从来没有调用过委托方法,也从来没有抛出过异常(我知道我没有在这里分配它们,但即使我这样做了也没关系)。它只是一片空白。为什么
SetSource
不能代替
Source
?我问这个问题的原因是,我正在尝试对电影文件进行简单的模糊处理,以便使用我们的应用程序的人至少需要付出一些努力来窃取受版权保护的内容。这需要在将流传递到
MediaElement


编辑另一条相关信息是,媒体元素上的状态更改回调在第二个版本中被调用一次(状态立即“关闭”)。

根据这一点,问题是
TestMedia.AutoPlay=true就在
SetSource
之后。这两种方法之间似乎应该有一些延迟。

你调试过吗?@bash.d我不明白。我把它归结为一个简单的测试用例,其中预期的行为与我预期的不同<在第二种情况下,code>MediaElement
似乎在默默地失败,尽管理论上它们使用的是完全相同的文件。除此之外,我只能在从
MediaElement
中获取信息时进行调试,而这并不表示任何内容。我的意思是逐步完成它。。。有时你会得到不同的结果,实际上你可能会有时间问题。虽然这真的是一个简单的案例。是的,我已经讲过了,但是所有相关的细节都发生在我无法进入的地方(在Windows运行时内)。
流的状态更改了
?@bash.d我不知道你在哪里说的,你能指出吗?