在 Windows Phone 中播放独立存储中的媒体文件?
我需要播放独立存储中的音乐文件。我按照这个方法,
MediaElement media = new MediaElement();
using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream fileStream = myIsolatedStorage.OpenFile(FileName, FileMode.Open, FileAccess.Read))
{
media.SetSource(fileStream);
media.Play();
}
}
无法播放音乐文件。当我创建媒体元素 Xaml 并设置该元素的源时,效果很好。问题是,我必须动态创建所有控件。
请建议我如何解决这个问题...
谢谢
I need to play music file from the isolated storage. i did by this way,
MediaElement media = new MediaElement();
using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream fileStream = myIsolatedStorage.OpenFile(FileName, FileMode.Open, FileAccess.Read))
{
media.SetSource(fileStream);
media.Play();
}
}
I can't play the music file. When i created media element Xaml and set source that element this works fine. The problem is, i have to create all controls dynamically.
Pls suggest me how to resolve this pblm...
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将此 MediaElement 添加到可视化树中。或者换句话说,MediaElement 应该是 PhoneApplicationPage 的一部分。
假设您的页面中有一个网格,并将此 MediaElement 添加到网格中。
然后您可以设置 Source 以及 Play() 媒体。
You need to add this MediaElement to your visual tree. Or in other words the MediaElement should be part of your PhoneApplicationPage.
Assume you have a Grid inside your page and add this MediaElement to the grid.
And then you can set the Source as well as Play() the media.